From 8d51ce2bea6b004b2a96981c4bd9b79d5afca0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:31:13 -0500 Subject: [PATCH] feat: migrate performance --- .vscode/settings.json | 1 + packages/scripts/src/protos.ts | 1 + .../performance/components/TierBreakdown.tsx | 82 ------------------- .../src/app/tools/performance/page.tsx | 6 +- packages/website-legacy/tsconfig.json | 6 +- .../components/Performance}/BodyLoader.tsx | 0 .../src/components/Performance}/Controls.tsx | 2 +- .../src/components/Performance}/Header.tsx | 6 +- .../Performance/PerformanceInfo.tsx} | 2 +- .../Performance}/PlayerCountControl.tsx | 4 +- .../src/components/Performance}/RowLoader.tsx | 4 +- .../src/components/Performance}/Table.tsx | 2 +- .../src/components/Performance}/TankRow.tsx | 15 ++-- .../src/components/Performance}/Tanks.tsx | 51 +++++++----- .../src/components/Performance}/Total.tsx | 25 +++--- .../src/pages/tools/performance/index.astro | 8 ++ .../src/pages/tools/performance/index.tsx | 26 ++++++ .../stores/tankPerformancePersistent/index.ts | 17 ++-- .../stores/tankPerformanceSort/constants.ts | 2 +- .../src/stores/tankPerformanceSort/index.ts | 11 ++- 20 files changed, 122 insertions(+), 149 deletions(-) delete mode 100644 packages/website-legacy/src/app/tools/performance/components/TierBreakdown.tsx rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/BodyLoader.tsx (100%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/Controls.tsx (61%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/Header.tsx (89%) rename packages/{website-legacy/src/app/tools/performance/components/Info.tsx => website/src/components/Performance/PerformanceInfo.tsx} (96%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/PlayerCountControl.tsx (88%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/RowLoader.tsx (82%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/Table.tsx (88%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/TankRow.tsx (84%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/Tanks.tsx (70%) rename packages/{website-legacy/src/app/tools/performance/components => website/src/components/Performance}/Total.tsx (82%) create mode 100644 packages/website/src/pages/tools/performance/index.astro create mode 100644 packages/website/src/pages/tools/performance/index.tsx diff --git a/.vscode/settings.json b/.vscode/settings.json index 26fe90b8d..af00b7dc4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -104,6 +104,7 @@ "mmnow", "modeltransform", "MURICA", + "nanostores", "NEGATIVEX", "NEGATIVEY", "NEGATIVEZ", diff --git a/packages/scripts/src/protos.ts b/packages/scripts/src/protos.ts index 322e235b1..8dbf0d03b 100644 --- a/packages/scripts/src/protos.ts +++ b/packages/scripts/src/protos.ts @@ -31,6 +31,7 @@ const args = [ '--ts_proto_opt=oneof=unions-value', '--ts_proto_opt=removeEnumPrefix=true', '--ts_proto_opt=unrecognizedEnum=false', + '--ts_proto_opt=snakeToCamel=false', '--ts_proto_out=.', ...files.map((file) => `${ROOT}/${file}`), ]; diff --git a/packages/website-legacy/src/app/tools/performance/components/TierBreakdown.tsx b/packages/website-legacy/src/app/tools/performance/components/TierBreakdown.tsx deleted file mode 100644 index b1fee6101..000000000 --- a/packages/website-legacy/src/app/tools/performance/components/TierBreakdown.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { - formatCompact, - TANK_CLASSES, - TankClass, - Tier, - TIER_ROMAN_NUMERALS, -} from '@blitzkit/core'; -import strings from '@blitzkit/core/lang/en-US.json'; -import { ResponsiveBar } from '@nivo/bar'; -import { Box, Flex, Heading } from '@radix-ui/themes'; -import { times } from 'lodash-es'; -import { use } from 'react'; -import { nivoTheme } from '../../../../core/nivo/theme'; - -export function TierBreakdown() { - const awaitedAverageDefinitionsArray = use(averageDefinitionsArray); - const awaitedTankDefinitions = use(tankDefinitions); - - return ( - - - - Players (30d) per tier - - - - { - const tier = (index + 1) as Tier; - const tierTanks = awaitedAverageDefinitionsArray.filter( - ({ id }) => awaitedTankDefinitions[id]?.tier === tier, - ); - const populations: Record = { - 'AT-SPG': 0, - heavyTank: 0, - lightTank: 0, - mediumTank: 0, - }; - - tierTanks.forEach((stats) => { - const tank = awaitedTankDefinitions[stats.id]; - populations[tank.class] += - stats.mu.battles * stats.samples.d_30; - }); - - TANK_CLASSES.forEach((tankClass) => { - populations[tankClass] = Math.round(populations[tankClass]); - }); - - return { tier: TIER_ROMAN_NUMERALS[tier], ...populations }; - })} - keys={[...TANK_CLASSES].reverse()} - indexBy="tier" - colors={{ scheme: 'dark2' }} - label={(d) => formatCompact(d.value as number)} - margin={{ right: 96, bottom: 20, left: 40 }} - legendLabel={(d) => - strings.common.tank_class_short[d.id as TankClass] - } - axisLeft={{ - tickSize: 0, - format: (value) => formatCompact(value as number), - }} - axisBottom={{ tickSize: 0 }} - legends={[ - { - dataFrom: 'keys', - anchor: 'bottom-right', - direction: 'column', - translateX: 120, - itemsSpacing: 4, - itemWidth: 100, - itemHeight: 20, - }, - ]} - /> - - - - ); -} diff --git a/packages/website-legacy/src/app/tools/performance/page.tsx b/packages/website-legacy/src/app/tools/performance/page.tsx index 6f8dd4aaf..4afddcf47 100644 --- a/packages/website-legacy/src/app/tools/performance/page.tsx +++ b/packages/website-legacy/src/app/tools/performance/page.tsx @@ -1,7 +1,7 @@ +import { Controls } from '../../../../../website/src/components/Performance/Controls'; +import { Info } from '../../../../../website/src/components/Performance/PerformanceInfo'; +import { TankTable } from '../../../../../website/src/components/Performance/Table'; import { PageWrapper } from '../../../components/PageWrapper'; -import { Controls } from './components/Controls'; -import { Info } from './components/Info'; -import { TankTable } from './components/Table'; export default function Page() { return ( diff --git a/packages/website-legacy/tsconfig.json b/packages/website-legacy/tsconfig.json index 6e8705550..38178c913 100644 --- a/packages/website-legacy/tsconfig.json +++ b/packages/website-legacy/tsconfig.json @@ -7,5 +7,9 @@ } ] }, - "include": ["src/**/*", ".next/types/**/*.ts"] + "include": [ + "src/**/*", + ".next/types/**/*.ts", + "../website/src/components/Performance/PerformanceInfo.tsx" + ] } diff --git a/packages/website-legacy/src/app/tools/performance/components/BodyLoader.tsx b/packages/website/src/components/Performance/BodyLoader.tsx similarity index 100% rename from packages/website-legacy/src/app/tools/performance/components/BodyLoader.tsx rename to packages/website/src/components/Performance/BodyLoader.tsx diff --git a/packages/website-legacy/src/app/tools/performance/components/Controls.tsx b/packages/website/src/components/Performance/Controls.tsx similarity index 61% rename from packages/website-legacy/src/app/tools/performance/components/Controls.tsx rename to packages/website/src/components/Performance/Controls.tsx index d77e1d587..5408229d2 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Controls.tsx +++ b/packages/website/src/components/Performance/Controls.tsx @@ -1,4 +1,4 @@ -import { FilterControl } from '../../../../../../website/src/components/TankSearch/components/FilterControl'; +import { FilterControl } from '../TankSearch/components/FilterControl'; import { PlayerCountControl } from './PlayerCountControl'; export function Controls() { diff --git a/packages/website-legacy/src/app/tools/performance/components/Header.tsx b/packages/website/src/components/Performance/Header.tsx similarity index 89% rename from packages/website-legacy/src/app/tools/performance/components/Header.tsx rename to packages/website/src/components/Performance/Header.tsx index 2dbf46c42..a6757f6e8 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Header.tsx +++ b/packages/website/src/components/Performance/Header.tsx @@ -4,12 +4,12 @@ import { CaretUpIcon, } from '@radix-ui/react-icons'; import { Flex, IconButton, Table } from '@radix-ui/themes'; -import { StickyColumnHeaderCell } from '../../../../components/StickyColumnHeaderCell'; -import * as TankPerformanceSort from '../../../../stores/tankPerformanceSort'; +import { TankPerformanceSort } from '../../stores/tankPerformanceSort'; import { TankPerformanceSortTypeNames, TankPerformanceSortTypeNamesArray, -} from '../../../../stores/tankPerformanceSort/constants'; +} from '../../stores/tankPerformanceSort/constants'; +import { StickyColumnHeaderCell } from '../StickyColumnHeaderCell'; export function Header() { const sort = TankPerformanceSort.use(); diff --git a/packages/website-legacy/src/app/tools/performance/components/Info.tsx b/packages/website/src/components/Performance/PerformanceInfo.tsx similarity index 96% rename from packages/website-legacy/src/app/tools/performance/components/Info.tsx rename to packages/website/src/components/Performance/PerformanceInfo.tsx index e54e681bc..a960400c2 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Info.tsx +++ b/packages/website/src/components/Performance/PerformanceInfo.tsx @@ -9,7 +9,7 @@ import { Callout, Flex } from '@radix-ui/themes'; const discoveredIdsDefinitions = await fetchDiscoveredIdsDefinitions(); const averageDefinitions = await fetchAverageDefinitions(); -export function Info() { +export function PerformanceInfo() { const samples = discoveredIdsDefinitions.count; const minutesAgo = Math.floor( (Date.now() - averageDefinitions.time) / (1000 * 60), diff --git a/packages/website-legacy/src/app/tools/performance/components/PlayerCountControl.tsx b/packages/website/src/components/Performance/PlayerCountControl.tsx similarity index 88% rename from packages/website-legacy/src/app/tools/performance/components/PlayerCountControl.tsx rename to packages/website/src/components/Performance/PlayerCountControl.tsx index 550194f75..6a3d1e810 100644 --- a/packages/website-legacy/src/app/tools/performance/components/PlayerCountControl.tsx +++ b/packages/website/src/components/Performance/PlayerCountControl.tsx @@ -1,6 +1,6 @@ import { Flex, Select, Text } from '@radix-ui/themes'; -import * as TankPerformancePersistent from '../../../../stores/tankPerformancePersistent'; -import { PlayerCountPeriod } from '../../../../stores/tankPerformancePersistent/constants'; +import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent'; +import { PlayerCountPeriod } from '../../stores/tankPerformancePersistent/constants'; export function PlayerCountControl() { const playerCountPeriod = TankPerformancePersistent.use( diff --git a/packages/website-legacy/src/app/tools/performance/components/RowLoader.tsx b/packages/website/src/components/Performance/RowLoader.tsx similarity index 82% rename from packages/website-legacy/src/app/tools/performance/components/RowLoader.tsx rename to packages/website/src/components/Performance/RowLoader.tsx index 5349eecc0..10094307f 100644 --- a/packages/website-legacy/src/app/tools/performance/components/RowLoader.tsx +++ b/packages/website/src/components/Performance/RowLoader.tsx @@ -1,8 +1,8 @@ import { Skeleton, Table } from '@radix-ui/themes'; import { times } from 'lodash-es'; import { memo, useRef } from 'react'; -import { useIntersection } from '../../../../hooks/useIntersection'; -import { TankPerformanceSortTypeNamesArray } from '../../../../stores/tankPerformanceSort/constants'; +import { useIntersection } from '../../hooks/useIntersection'; +import { TankPerformanceSortTypeNamesArray } from '../../stores/tankPerformanceSort/constants'; interface RowLoaderProps { onIntersection?: () => void; diff --git a/packages/website-legacy/src/app/tools/performance/components/Table.tsx b/packages/website/src/components/Performance/Table.tsx similarity index 88% rename from packages/website-legacy/src/app/tools/performance/components/Table.tsx rename to packages/website/src/components/Performance/Table.tsx index bc448aa38..d3d64ac22 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Table.tsx +++ b/packages/website/src/components/Performance/Table.tsx @@ -1,6 +1,6 @@ import { Flex } from '@radix-ui/themes'; import { Suspense } from 'react'; -import { StickyTableRoot } from '../../../../components/StickyTableRoot'; +import { StickyTableRoot } from '../StickyTableRoot'; import { BodyLoader } from './BodyLoader'; import { Header } from './Header'; import { Tanks } from './Tanks'; diff --git a/packages/website-legacy/src/app/tools/performance/components/TankRow.tsx b/packages/website/src/components/Performance/TankRow.tsx similarity index 84% rename from packages/website-legacy/src/app/tools/performance/components/TankRow.tsx rename to packages/website/src/components/Performance/TankRow.tsx index a7a23962a..278bbcdfa 100644 --- a/packages/website-legacy/src/app/tools/performance/components/TankRow.tsx +++ b/packages/website/src/components/Performance/TankRow.tsx @@ -1,22 +1,23 @@ import { TankDefinition, - averageDefinitions, + fetchAverageDefinitions, formatCompact, } from '@blitzkit/core'; import { Table } from '@radix-ui/themes'; -import { memo, use } from 'react'; -import { TankRowHeaderCell } from '../../../../components/TankRowHeaderCell'; -import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio'; -import * as TankPerformancePersistent from '../../../../stores/tankPerformancePersistent'; +import { memo } from 'react'; +import { useAveragesExclusionRatio } from '../../hooks/useAveragesExclusionRatio'; +import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent'; +import { TankRowHeaderCell } from '../TankRowHeaderCell'; interface TankRowProps { tank: TankDefinition; } +const averageDefinitions = await fetchAverageDefinitions(); + export const TankRow = memo( ({ tank }) => { - const awaitedAverageDefinitions = use(averageDefinitions); - const averages = awaitedAverageDefinitions.averages[tank.id]; + const averages = averageDefinitions.averages[tank.id]; const ratio = useAveragesExclusionRatio(); const playerCountPeriod = TankPerformancePersistent.use( (state) => state.playerCountPeriod, diff --git a/packages/website-legacy/src/app/tools/performance/components/Tanks.tsx b/packages/website/src/components/Performance/Tanks.tsx similarity index 70% rename from packages/website-legacy/src/app/tools/performance/components/Tanks.tsx rename to packages/website/src/components/Performance/Tanks.tsx index 9a42b472b..41260f649 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Tanks.tsx +++ b/packages/website/src/components/Performance/Tanks.tsx @@ -1,6 +1,12 @@ +import { fetchAverageDefinitions, fetchTankDefinitions } from '@blitzkit/core'; +import { useStore } from '@nanostores/react'; import { Table } from '@radix-ui/themes'; import { times } from 'lodash-es'; -import { Suspense, use, useEffect, useMemo, useState } from 'react'; +import { Suspense, useEffect, useMemo, useState } from 'react'; +import { filterTank } from '../../core/blitzkit/filterTank'; +import { $tankFilters } from '../../stores/tankFilters'; +import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent'; +import { TankPerformanceSort } from '../../stores/tankPerformanceSort'; import { RowLoader } from './RowLoader'; import { TankRow } from './TankRow'; import { Total } from './Total'; @@ -8,94 +14,101 @@ import { Total } from './Total'; const PREVIEW_COUNT = 10; const DEFAULT_LOADED_ROWS = 25; +const tankDefinitions = await fetchTankDefinitions(); +const averageDefinitionsArray = await fetchAverageDefinitions().then( + ({ averages }) => + Object.entries(averages).map(([id, average]) => ({ + id: Number(id), + ...average, + })), +); + export function Tanks() { - const awaitedTankDefinitions = use(tankDefinitions); - const awaitedAverageDefinitionsArray = use(averageDefinitionsArray); - const filters = TankFilters.use(); const sort = TankPerformanceSort.use(); const tankPerformancePersistentStore = TankPerformancePersistent.useStore(); + const filters = useStore($tankFilters); const tanksSorted = useMemo(() => { const { playerCountPeriod } = tankPerformancePersistentStore.getState(); switch (sort.type) { case 'accuracy': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.hits / a.mu.shots - b.mu.hits / b.mu.shots), ); case 'capturePoints': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.capture_points / a.mu.battles - b.mu.capture_points / b.mu.battles), ); case 'damage': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.damage_dealt / a.mu.battles - b.mu.damage_dealt / b.mu.battles), ); case 'damageRatio': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.damage_dealt / a.mu.damage_received - b.mu.damage_dealt / b.mu.damage_received), ); case 'damageTaken': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.damage_received / a.mu.battles - b.mu.damage_received / b.mu.battles), ); case 'hits': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.hits / a.mu.battles - b.mu.hits / b.mu.battles), ); case 'kills': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.frags / a.mu.battles - b.mu.frags / b.mu.battles), ); case 'shots': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.shots / a.mu.battles - b.mu.shots / b.mu.battles), ); case 'players': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.samples[playerCountPeriod] - b.samples[playerCountPeriod]), ); case 'spots': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.spotted / a.mu.battles - b.mu.spotted / b.mu.battles), ); case 'survival': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.survived_battles / a.mu.battles - b.mu.survived_battles / b.mu.battles), ); case 'winrate': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.wins / a.mu.battles - b.mu.wins / b.mu.battles), ); case 'xp': - return awaitedAverageDefinitionsArray.sort( + return averageDefinitionsArray.sort( (a, b) => sort.direction * (a.mu.xp / a.mu.battles - b.mu.xp / b.mu.battles), ); @@ -103,7 +116,7 @@ export function Tanks() { }, [sort]); const tanks = useMemo(() => { return tanksSorted.filter((tank) => - filterTank(filters, awaitedTankDefinitions[tank.id]), + filterTank(filters, tankDefinitions.tanks[tank.id]), ); }, [filters, sort]); const [loadedRows, setLoadedRows] = useState(DEFAULT_LOADED_ROWS); @@ -117,7 +130,7 @@ export function Tanks() { {tanks.slice(0, loadedRows).map((averages) => { - const tank = awaitedTankDefinitions[averages.id]; + const tank = tankDefinitions.tanks[averages.id]; if (tank === undefined) return null; diff --git a/packages/website-legacy/src/app/tools/performance/components/Total.tsx b/packages/website/src/components/Performance/Total.tsx similarity index 82% rename from packages/website-legacy/src/app/tools/performance/components/Total.tsx rename to packages/website/src/components/Performance/Total.tsx index c7b788a5b..b063a6161 100644 --- a/packages/website-legacy/src/app/tools/performance/components/Total.tsx +++ b/packages/website/src/components/Performance/Total.tsx @@ -1,22 +1,27 @@ import { - averageDefinitions, - AverageDefinitionsEntryWithId, - BlitzkitStats, + AverageDefinitionsEntry, + fetchAverageDefinitions, formatCompact, + type BlitzkitStats, } from '@blitzkit/core'; import { Table } from '@radix-ui/themes'; -import { memo, use, useCallback } from 'react'; -import { StickyRowHeaderCell } from '../../../../components/StickyRowHeaderCell'; -import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio'; -import * as TankPerformancePersistent from '../../../../stores/tankPerformancePersistent'; +import { memo, useCallback } from 'react'; +import { useAveragesExclusionRatio } from '../../hooks/useAveragesExclusionRatio'; +import { TankPerformancePersistent } from '../../stores/tankPerformancePersistent'; +import { StickyRowHeaderCell } from '../StickyRowHeaderCell'; + +interface AverageDefinitionsEntryWithId extends AverageDefinitionsEntry { + id: number; +} interface TotalProps { tanks: AverageDefinitionsEntryWithId[]; } +const averageDefinitions = await fetchAverageDefinitions(); + export const Total = memo( ({ tanks }) => { - const awaitedAverageDefinitions = use(averageDefinitions); const playerCountPeriod = TankPerformancePersistent.use( (state) => state.playerCountPeriod, ); @@ -53,9 +58,7 @@ export const Total = memo( {(winrate * 100).toFixed(1)}% - {formatCompact( - ratio * awaitedAverageDefinitions.samples[playerCountPeriod], - )} + {formatCompact(ratio * averageDefinitions.samples[playerCountPeriod])} {Math.round(damage).toLocaleString()} diff --git a/packages/website/src/pages/tools/performance/index.astro b/packages/website/src/pages/tools/performance/index.astro new file mode 100644 index 000000000..4255c07ef --- /dev/null +++ b/packages/website/src/pages/tools/performance/index.astro @@ -0,0 +1,8 @@ +--- +import { Page } from '.'; +import ToolLayout from '../../../layouts/ToolLayout.astro'; +--- + + + + diff --git a/packages/website/src/pages/tools/performance/index.tsx b/packages/website/src/pages/tools/performance/index.tsx new file mode 100644 index 000000000..5815b806d --- /dev/null +++ b/packages/website/src/pages/tools/performance/index.tsx @@ -0,0 +1,26 @@ +import { PageWrapper } from '../../../components/PageWrapper'; +import { Controls } from '../../../components/Performance/Controls'; +import { PerformanceInfo } from '../../../components/Performance/PerformanceInfo'; +import { TankTable } from '../../../components/Performance/Table'; +import { TankPerformancePersistent } from '../../../stores/tankPerformancePersistent'; +import { TankPerformanceSort } from '../../../stores/tankPerformanceSort'; + +export function Page() { + return ( + + + + + + ); +} + +function Content() { + return ( + + + + + + ); +} diff --git a/packages/website/src/stores/tankPerformancePersistent/index.ts b/packages/website/src/stores/tankPerformancePersistent/index.ts index d0b061c3f..e1b845c88 100644 --- a/packages/website/src/stores/tankPerformancePersistent/index.ts +++ b/packages/website/src/stores/tankPerformancePersistent/index.ts @@ -8,14 +8,13 @@ export interface TankPerformancePersistent { playerCountPeriod: PlayerCountPeriod; } -export const { Provider, use, useMutation, useStore } = createContextualStore( - () => - create()( - persist( - subscribeWithSelector(() => ({ - playerCountPeriod: PlayerCountPeriod.ThisMonth, - })), - { name: 'tank-performance', merge: (a, b) => lodash.merge(b, a) }, - ), +export const TankPerformancePersistent = createContextualStore(() => + create()( + persist( + subscribeWithSelector(() => ({ + playerCountPeriod: PlayerCountPeriod.ThisMonth, + })), + { name: 'tank-performance', merge: (a, b) => lodash.merge(b, a) }, ), + ), ); diff --git a/packages/website/src/stores/tankPerformanceSort/constants.ts b/packages/website/src/stores/tankPerformanceSort/constants.ts index 2c619b8a6..dd519eb98 100644 --- a/packages/website/src/stores/tankPerformanceSort/constants.ts +++ b/packages/website/src/stores/tankPerformanceSort/constants.ts @@ -1,4 +1,4 @@ -import { TankPerformanceSortType } from '.'; +import type { TankPerformanceSortType } from '.'; export const TankPerformanceSortTypeNames = { winrate: 'Winrate', diff --git a/packages/website/src/stores/tankPerformanceSort/index.ts b/packages/website/src/stores/tankPerformanceSort/index.ts index 5269453a2..e6a2f8c9a 100644 --- a/packages/website/src/stores/tankPerformanceSort/index.ts +++ b/packages/website/src/stores/tankPerformanceSort/index.ts @@ -9,10 +9,9 @@ export interface TankPerformanceSort { direction: -1 | 1; } -export const { Provider, use, useMutation, useStore } = createContextualStore( - () => - create()(() => ({ - type: 'winrate', - direction: -1, - })), +export const TankPerformanceSort = createContextualStore(() => + create()(() => ({ + type: 'winrate', + direction: -1, + })), );