@four-leaf-studios/rl-overlay 1.0.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/dist/index.cjs.js +10718 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +10691 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/types/Overlay.d.ts +19 -0
- package/dist/types/Player.d.ts +7 -0
- package/dist/types/PlayerBoost.d.ts +8 -0
- package/dist/types/Replay.d.ts +3 -0
- package/dist/types/Scoreboard.d.ts +3 -0
- package/dist/types/ScoreboardGameBox.d.ts +7 -0
- package/dist/types/ScoreboardSeriesBox.d.ts +7 -0
- package/dist/types/ScoreboardTeam.d.ts +7 -0
- package/dist/types/StatItem.d.ts +13 -0
- package/dist/types/TargetBoost.d.ts +3 -0
- package/dist/types/TargetPlayer.d.ts +3 -0
- package/dist/types/TargetPlayerLocation.d.ts +7 -0
- package/dist/types/TargetPlayerStats.d.ts +7 -0
- package/dist/types/Team.d.ts +8 -0
- package/dist/types/Teams.d.ts +3 -0
- package/dist/types/Timer.d.ts +3 -0
- package/dist/types/context/BroadcastContext.d.ts +7 -0
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/hooks/useOverlayStyles.d.ts +12 -0
- package/dist/types/hooks/useReplay.d.ts +7 -0
- package/dist/types/hooks/useShowGameComponents.d.ts +2 -0
- package/dist/types/hooks/useTargetPlayer.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/mockBroadcast.d.ts +18 -0
- package/package.json +50 -0
- package/rollup.config.js +55 -0
- package/src/Overlay.tsx +100 -0
- package/src/Player.tsx +31 -0
- package/src/PlayerBoost.tsx +26 -0
- package/src/Replay.tsx +18 -0
- package/src/Scoreboard.tsx +58 -0
- package/src/ScoreboardGameBox.tsx +25 -0
- package/src/ScoreboardSeriesBox.tsx +44 -0
- package/src/ScoreboardTeam.tsx +39 -0
- package/src/StatItem.tsx +31 -0
- package/src/TargetBoost.tsx +63 -0
- package/src/TargetPlayer.tsx +56 -0
- package/src/TargetPlayerLocation.tsx +27 -0
- package/src/TargetPlayerStats.tsx +25 -0
- package/src/Team.tsx +45 -0
- package/src/Teams.tsx +13 -0
- package/src/Timer.tsx +24 -0
- package/src/assets/overlay-testing-background.png +0 -0
- package/src/context/BroadcastContext.tsx +21 -0
- package/src/css/reset.css +280 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useOverlayStyles.ts +107 -0
- package/src/hooks/useReplay.ts +21 -0
- package/src/hooks/useShowGameComponents.ts +14 -0
- package/src/hooks/useTargetPlayer.ts +21 -0
- package/src/index.ts +3 -0
- package/src/types.d.ts +59 -0
- package/test-overlay/README.md +12 -0
- package/test-overlay/eslint.config.js +33 -0
- package/test-overlay/index.html +13 -0
- package/test-overlay/package.json +27 -0
- package/test-overlay/public/mock-css.css +733 -0
- package/test-overlay/public/vite.svg +1 -0
- package/test-overlay/src/App.jsx +28 -0
- package/test-overlay/src/index.css +0 -0
- package/test-overlay/src/main.jsx +10 -0
- package/test-overlay/src/mockBroadcast.js +33 -0
- package/test-overlay/vite.config.js +7 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEvent, useEventSelector } from "@four-leaf-studios/rl-socket-hook";
|
|
2
|
+
|
|
3
|
+
const useReplay = () => {
|
|
4
|
+
const replayEndEvent = useEvent("game:replay_end");
|
|
5
|
+
const replayStartEvent = useEvent("game:replay_start");
|
|
6
|
+
const isReplay = useEventSelector(
|
|
7
|
+
"game:update_state",
|
|
8
|
+
(state) => state?.game?.isReplay
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const disabled = (!replayStartEvent && !isReplay) || replayEndEvent;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
active: !disabled,
|
|
15
|
+
replayEndEvent,
|
|
16
|
+
replayStartEvent,
|
|
17
|
+
isReplay,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default useReplay;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEvent, useEventSelector } from "@four-leaf-studios/rl-socket-hook";
|
|
2
|
+
|
|
3
|
+
const useShowGameComponents = () => {
|
|
4
|
+
const gameInitialized = useEvent("game:initialized");
|
|
5
|
+
const matchDestroyed = useEvent("game:match_destroyed");
|
|
6
|
+
const hasGame = useEventSelector(
|
|
7
|
+
"game:update_state",
|
|
8
|
+
(state) => state?.hasGame
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return !!gameInitialized && !!hasGame && !matchDestroyed;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default useShowGameComponents;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEventSelector } from "@four-leaf-studios/rl-socket-hook";
|
|
2
|
+
|
|
3
|
+
const useTargetPlayer = () => {
|
|
4
|
+
const targetPlayer = useEventSelector("game:update_state", (state) => {
|
|
5
|
+
if (!state?.game.hasTarget) return null;
|
|
6
|
+
|
|
7
|
+
const target = state?.game?.target;
|
|
8
|
+
|
|
9
|
+
if (!state?.players || !target) return null;
|
|
10
|
+
|
|
11
|
+
const player = Object.values(state?.players)?.find(
|
|
12
|
+
(player) => player.id === target
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
return player;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return targetPlayer;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default useTargetPlayer;
|
package/src/index.ts
ADDED
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type Team = {
|
|
2
|
+
id: "0" | "1";
|
|
3
|
+
broadcast_id: string | null;
|
|
4
|
+
session_id: string | null;
|
|
5
|
+
organization_id: string | null;
|
|
6
|
+
color_id: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
series_score: number;
|
|
9
|
+
logo: string | null;
|
|
10
|
+
side: "blue" | "orange";
|
|
11
|
+
created_at: string;
|
|
12
|
+
created_by: string | null;
|
|
13
|
+
} & {
|
|
14
|
+
players?: Player[];
|
|
15
|
+
organization?: Organization;
|
|
16
|
+
color?: Color;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type Player = {
|
|
20
|
+
id: string;
|
|
21
|
+
user_id: string | null;
|
|
22
|
+
team_id: string | null;
|
|
23
|
+
name: string;
|
|
24
|
+
picture: string | null;
|
|
25
|
+
created_at: string;
|
|
26
|
+
created_by: string | null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type Organization = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
logo: string | null;
|
|
33
|
+
created_at: string;
|
|
34
|
+
created_by: string | null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type Color = {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
primary_color: string;
|
|
41
|
+
secondary_color: string;
|
|
42
|
+
mutual_color: string | null;
|
|
43
|
+
created_at: string;
|
|
44
|
+
created_by: string | null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type Broadcast = {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
status: "active" | "inactive";
|
|
51
|
+
overlay_id: string | null;
|
|
52
|
+
featured: boolean;
|
|
53
|
+
top_info_text: string | null;
|
|
54
|
+
series_number: number;
|
|
55
|
+
created_at: string;
|
|
56
|
+
created_by: string | null;
|
|
57
|
+
teams: Team[];
|
|
58
|
+
overlay?: Overlay;
|
|
59
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# React + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
{ ignores: ['dist'] },
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.{js,jsx}'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: 2020,
|
|
12
|
+
globals: globals.browser,
|
|
13
|
+
parserOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
ecmaFeatures: { jsx: true },
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: {
|
|
20
|
+
'react-hooks': reactHooks,
|
|
21
|
+
'react-refresh': reactRefresh,
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
...js.configs.recommended.rules,
|
|
25
|
+
...reactHooks.configs.recommended.rules,
|
|
26
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
|
27
|
+
'react-refresh/only-export-components': [
|
|
28
|
+
'warn',
|
|
29
|
+
{ allowConstantExport: true },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "test-overlay",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"react": "^19.0.0",
|
|
14
|
+
"react-dom": "^19.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@eslint/js": "^9.22.0",
|
|
18
|
+
"@types/react": "^19.0.10",
|
|
19
|
+
"@types/react-dom": "^19.0.4",
|
|
20
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
21
|
+
"eslint": "^9.22.0",
|
|
22
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
23
|
+
"eslint-plugin-react-refresh": "^0.4.19",
|
|
24
|
+
"globals": "^16.0.0",
|
|
25
|
+
"vite": "^6.3.1"
|
|
26
|
+
}
|
|
27
|
+
}
|