Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Partykit for whole-app sync #349

Draft
wants to merge 103 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
6da58bb
upgrade typescript, add partykit
noahm Jun 23, 2024
6636fe7
initial working-ish prototype
noahm Jun 23, 2024
2e86cd6
set base font family on root rather than body
noahm Jun 27, 2024
687eba3
convert major state management to redux
noahm Jul 3, 2024
8d89248
Now it actually works with redux!
noahm Jul 3, 2024
fd2f0a3
re-sort dependencies
noahm Jul 3, 2024
60e7369
make config slice naturally json compatible
noahm Jul 3, 2024
18305be
speculative wireup for new partykit networking
noahm Jul 4, 2024
82a22c9
reorganize further so server can build
noahm Jul 4, 2024
8c763eb
move game data loading out of redux
noahm Jul 11, 2024
0da3104
add client-side routing, pull room from url
noahm Jul 12, 2024
6cee1a4
nicer UI while connecting
noahm Jul 12, 2024
9e05f4e
add deployed partykit host
noahm Jul 12, 2024
6ac6102
restore behavior of newest drawings at the top
noahm Jul 12, 2024
0aea805
merge main, dedupe deps
noahm Jul 12, 2024
a36c853
add vercel.json for client-side routing support
noahm Jul 12, 2024
acb594c
add event state slice
noahm Jul 12, 2024
1774363
add persisted webpack cache
noahm Jul 13, 2024
7e6eaea
add basic cab management
noahm Jul 13, 2024
050bf29
add standalone obs source views
noahm Jul 13, 2024
2acb83b
allow new slices to retain their default state
noahm Jul 13, 2024
326c40b
prepopulate default cab
noahm Jul 13, 2024
07a5109
create default cab via lazy initialization
noahm Jul 13, 2024
a968254
non random initial state
noahm Jul 13, 2024
566d291
add very basic gql+codegen setup
noahm Jul 14, 2024
f05677b
remove unused zustand utils
noahm Jul 18, 2024
648e575
groundwork for entrants state from startgg
noahm Jul 18, 2024
a5cd475
move participatns tab from drawer to main view
noahm Jul 18, 2024
9dea64d
first working name imports
noahm Jul 18, 2024
453681c
prototype of set imports
noahm Jul 19, 2024
14c65c1
preliminary handling of prereqs
noahm Jul 19, 2024
060ad07
Merge remote-tracking branch 'origin/main' into partykit
noahm Jul 22, 2024
ac33403
Merge branch 'main' into partykit
noahm Jul 27, 2024
905134d
cleaner root handler
noahm Jul 27, 2024
e122c3b
temporary rollback for player name management
noahm Jul 27, 2024
1a0e53f
fix reorder by pick/ban
noahm Jul 27, 2024
16e0e39
fix jacket images in search results
noahm Jul 27, 2024
fa81259
Merge remote-tracking branch 'origin/main' into partykit
noahm Jul 28, 2024
63844a6
Merge branch 'main' into partykit
noahm Jul 28, 2024
a441fd6
use a single urql client instacne
noahm Jul 28, 2024
a710972
big steps towards startgg integration
noahm Aug 1, 2024
6b264cb
Merge remote-tracking branch 'origin/partykit' into partykit
noahm Aug 8, 2024
4cf7ae8
fix folders being nulled on defaults being applied
noahm Aug 9, 2024
2c0570d
fix selector warning from cab management
noahm Aug 9, 2024
ecbef09
use draw starting point to respect weights in redraws
noahm Aug 9, 2024
aa4985a
fix keeping protects and pocket picks in a redraw all situation
noahm Aug 9, 2024
3b246aa
prevent dupes in single chart redraw
noahm Aug 9, 2024
d402541
experimental draw blocklist
noahm Aug 9, 2024
4e11f60
add some real startgg integration
noahm Aug 13, 2024
935ec73
display url example inline
noahm Aug 13, 2024
2359225
pre-populate initial values for startgg inputs
noahm Aug 13, 2024
95384a9
persist startgg event info to localstorage
noahm Aug 13, 2024
39af9fa
fix swapping player positions by totally blowing up the drawing model
noahm Aug 14, 2024
d365278
added working reporting of results to startgg
noahm Aug 17, 2024
18499ef
display scores on drawing labels
noahm Aug 17, 2024
0a97fda
add player scores to obs sources
noahm Aug 17, 2024
85cdbce
fix reporting scores when only 1 player wins songs
noahm Aug 17, 2024
24a6080
very quick and dirty draw without match
noahm Aug 19, 2024
6699a3f
add quick picker for startgg events
noahm Aug 19, 2024
91f8908
Merge branch 'main' into partykit
noahm Aug 22, 2024
c41193f
another dedupe
noahm Aug 22, 2024
a79f4aa
experimental static cards display endpoint
noahm Sep 2, 2024
43eb438
early bits of multiconfig (all broken)
noahm Sep 4, 2024
7dff004
kind of working multiconfig
noahm Sep 6, 2024
d216e3f
select config after creating one
noahm Sep 7, 2024
6451cde
actually working multiconfig now!
noahm Sep 7, 2024
717d554
actually working copy/delete for configs
noahm Sep 7, 2024
2aab4f5
move config select/controls to drawer header
noahm Sep 7, 2024
03c1f24
Merge remote-tracking branch 'origin/main' into partykit
noahm Sep 7, 2024
22caf6d
fix crash when clearing drawings
noahm Sep 11, 2024
11f4c67
persist to supabase in addition to partykit
noahm Oct 3, 2024
61c991b
Add a "draw one chart" action
noahm Oct 3, 2024
f264ac7
fully wire up import from json
noahm Oct 3, 2024
89069b0
fix pocket picks for P1
noahm Oct 3, 2024
406d537
add newly added charts to the end
noahm Oct 3, 2024
3419e77
apply basis config over game's defaults
noahm Oct 3, 2024
916c098
bump partykit
noahm Oct 3, 2024
3b7c480
slightly nicer custom draws, support over 2 players again
noahm Oct 15, 2024
9c9a312
add new obs source for all player names
noahm Oct 15, 2024
db20cde
Merge branch 'main' into partykit
noahm Oct 19, 2024
ad1cca0
creating a config should be less confusing
noahm Oct 19, 2024
0de39e0
add delete draw action
noahm Oct 19, 2024
bce5f35
add gauntlet draws from startgg
noahm Oct 19, 2024
ca215b7
hide wins by names on gauntlet draws
noahm Oct 19, 2024
630c093
fix infinite loop on redraw/extra cards
noahm Oct 22, 2024
e5d2980
update alpha preview title in header
noahm Oct 22, 2024
f77c8b7
add almost working score editor for gauntlet draws
noahm Oct 22, 2024
43237d6
remove all concepts of app-wide selected config
noahm Oct 22, 2024
6b36423
add informative tooltip when draw is disabled
noahm Oct 22, 2024
733636e
allow cabs sidebar to show and hide
noahm Oct 22, 2024
e426240
put custom draw as the first tab
noahm Oct 22, 2024
d9c02e0
remove static cards
noahm Oct 23, 2024
b88dccf
fix normal obs cards source
noahm Oct 23, 2024
afd5cd6
add video link to landing page
noahm Oct 24, 2024
138d4f0
Move update manager to the top component
noahm Oct 24, 2024
5f835d7
safely return nothing when drawing is missing
noahm Oct 25, 2024
23d707b
Merge remote-tracking branch 'origin/main' into partykit
noahm Nov 7, 2024
4fa3946
Merge remote-tracking branch 'origin/main' into partykit
noahm Nov 13, 2024
8a8ca88
Merge remote-tracking branch 'origin/main' into partykit
noahm Jan 6, 2025
a66db55
remove artist blocklist
noahm Jan 6, 2025
26a9f05
Merge remote-tracking branch 'origin/main' into partykit
noahm Jan 7, 2025
2bbcb3e
catch errors in restoring state
noahm Jan 11, 2025
153c944
catch errors from upsert, respond to get reqs
noahm Jan 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generate one of your own for free at
# https://start.gg/admin/profile/developer
# Read more about start.gg auth here:
# https://developer.start.gg/docs/authentication
STARTGG_TOKEN=YOUR_TOKEN_HERE

# For persistence of the partykit state to somewhere more reliable
SUPABASE_URL=SOMETHING
SUPABASE_KEY=SOMETHING
17 changes: 17 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CodegenConfig } from "@graphql-codegen/cli";
import baseConfig from "./graphql.config";

const config: CodegenConfig = {
...baseConfig,
ignoreNoDocuments: false, // for better experience with the watcher
generates: {
"./src/startgg-gql/generated/": {
preset: "client",
presetConfig: {
fragmentMasking: false,
},
},
},
};

export default config;
14 changes: 14 additions & 0 deletions graphql.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "dotenv/config";

export default {
schema: [
{
"https://api.start.gg/gql/alpha": {
headers: {
Authorization: `Bearer ${process.env.STARTGG_TOKEN}`,
},
},
},
],
documents: ["./src/startgg-gql/*.ts"],
};
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@
"@blueprintjs/datetime2": "2.3.15",
"@blueprintjs/icons": "5.14.0",
"@blueprintjs/select": "5.3.3",
"@blueprintjs/table": "^5.2.2",
"@eslint/js": "^9.14.0",
"@graphql-codegen/cli": "5.0.3",
"@graphql-codegen/client-preset": "4.4.0",
"@lcdp/offline-plugin": "5.1.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
"@reduxjs/toolkit": "2.3.0",
"@supabase/supabase-js": "^2.45.4",
"@types/better-sqlite3": "7.6.11",
"@types/eslint__js": "^8.42.3",
"@types/fuzzy-search": "2.1.5",
Expand All @@ -58,6 +63,8 @@
"@types/papaparse": "patch:@types/papaparse@npm%3A5.3.14#~/.yarn/patches/@types-papaparse-npm-5.3.14-864eddd3a0.patch",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@urql/core": "^5.0.4",
"@urql/exchange-graphcache": "^7.1.2",
"autoprefixer": "10.4.20",
"axios": "1.7.7",
"babel-loader": "9.2.1",
Expand All @@ -71,13 +78,15 @@
"css-loader": "7.1.2",
"css-minimizer-webpack-plugin": "7.0.0",
"date-fns": "2.30.0",
"dotenv": "^16.4.5",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^5.0.0",
"favicons": "7.2.0",
"favicons-webpack-plugin": "6.0.1",
"fork-ts-checker-webpack-plugin": "9.0.2",
"fuzzy-search": "3.2.1",
"graphql": "^16.9.0",
"he": "1.2.0",
"html-entities": "2.5.2",
"html-loader": "5.1.0",
Expand All @@ -95,6 +104,8 @@
"normalize.css": "8.0.1",
"p-queue": "8.0.1",
"papaparse": "5.4.1",
"partykit": "0.0.111",
"partysocket": "1.0.1",
"peerjs": "2.0.0-beta.3",
"postcss": "8.4.49",
"postcss-loader": "8.1.1",
Expand All @@ -103,13 +114,16 @@
"react-dom": "18.3.1",
"react-error-boundary": "4.1.2",
"react-intl": "6.8.7",
"react-redux": "^9.1.2",
"react-refresh": "0.14.2",
"react-router-dom": "^6.24.1",
"sanitize-filename": "1.6.3",
"simfile-parser": "0.7.2",
"style-loader": "4.0.0",
"typescript": "5.6.3",
"typescript-eslint": "^8.14.0",
"undici": "6.21.0",
"urql": "^4.1.0",
"victory": "37.3.2",
"webpack": "5.96.1",
"webpack-cli": "5.1.4",
Expand Down
6 changes: 6 additions & 0 deletions partykit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://www.partykit.io/schema.json",
"name": "ddr-card-draw-party",
"main": "src/party/server.ts",
"compatibilityDate": "2024-06-21"
}
141 changes: 133 additions & 8 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "normalize.css";
import "@blueprintjs/core/lib/css/blueprint.css";
import "@blueprintjs/table/lib/css/table.css";
import "@blueprintjs/icons/lib/css/blueprint-icons.css";
import "@blueprintjs/select/lib/css/blueprint-select.css";
import "@blueprintjs/datetime2/lib/css/blueprint-datetime2.css";
Expand All @@ -8,21 +9,145 @@ import { FocusStyleManager } from "@blueprintjs/core";

FocusStyleManager.onlyShowFocusOnTabs();

import { DrawingList } from "./drawing-list";
import { UpdateManager } from "./update-manager";
import { DrawStateManager } from "./draw-state";
import { IntlProvider } from "./intl-provider";
import { Header } from "./header";
import { ThemeSyncWidget } from "./theme-toggle";
import { DropHandler } from "./drop-handler";
import { Provider } from "react-redux";
import { store } from "./state/store";
import { PartySocketManager } from "./party/client";
import { Provider as UrqlProvider } from "urql";

import {
createBrowserRouter,
Outlet,
RouterProvider,
useParams,
Link,
} from "react-router-dom";
import { CabManagement } from "./cab-management";
import { MainView } from "./main-view";
import { nanoid } from "nanoid";
import { urqlClient } from "./startgg-gql";

const router = createBrowserRouter([
{
path: "/",
Component: () => {
return (
<div style={{ padding: "1em" }}>
<h1>DDR Tools Event Mode</h1>
<h2 style={{ fontStyle: "italic" }}>Alpha Preview</h2>
<p>
You need to pick an event first. Would you like to:{" "}
<Link to={`/e/${nanoid()}`}>Create New Event?</Link>
</p>
<p>
No idea what this is?{" "}
<a href="https://youtu.be/4Gpj9jTNcfM">Here's a video</a> trying to
explain how to use it!
</p>
</div>
);
},
},
{
path: "e/:roomName",
element: <AppForRoom />,
},
{
path: "e/:roomName/cab/:cabId/source",
element: <ObsSource />,
children: [
{
path: "cards",
lazy: async () => {
const { CabCards } = await import("./obs-sources/cards");
return { Component: CabCards };
},
},
{
path: "title",
lazy: async () => {
const { CabTitle } = await import("./obs-sources/text");
return { Component: CabTitle };
},
},
{
path: "players",
lazy: async () => {
const { CabPlayers } = await import("./obs-sources/text");
return { Component: CabPlayers };
},
},
{
path: "p1",
lazy: async () => {
const { CabPlayer } = await import("./obs-sources/text");
return { element: <CabPlayer p={1} /> };
},
},
{
path: "p2",
lazy: async () => {
const { CabPlayer } = await import("./obs-sources/text");
return { element: <CabPlayer p={2} /> };
},
},
],
},
]);

function ObsSource() {
const params = useParams<"roomName" | "cabId">();
if (!params.roomName) {
return null;
}
return (
<Provider store={store}>
<PartySocketManager roomName={params.roomName}>
<IntlProvider>
<Outlet />
</IntlProvider>
</PartySocketManager>
</Provider>
);
}

function AppForRoom() {
const params = useParams<"roomName">();
if (!params.roomName) {
return null;
}
return (
<Provider store={store}>
<PartySocketManager roomName={params.roomName}>
<UrqlProvider value={urqlClient}>
<Header />
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "stretch",
flex: "1 1 0px",
overflow: "hidden",
}}
>
<CabManagement />
<MainView />
</div>
</UrqlProvider>
</PartySocketManager>
</Provider>
);
}

export function App() {
return (
<DrawStateManager defaultDataSet="a3">
<IntlProvider>
<ThemeSyncWidget />
<UpdateManager />
<Header />
<DrawingList />
<DropHandler />
</DrawStateManager>
<RouterProvider router={router} />
</IntlProvider>
);
}
41 changes: 0 additions & 41 deletions src/apply-default-config.tsx

This file was deleted.

Loading
Loading