mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: upgrade rest of them
This commit is contained in:
1 parent
fe4afdcbf0
commit
30e87743fc
63 files changed
+824
-1123
No files matched your search
@@ -1,7 +1,4 @@
|
||||
import { merge } from 'lodash-es';
|
||||
import { create } from 'zustand';
|
||||
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||
import { Varuna } from "varuna";
|
||||
|
||||
export interface WargamingLogin {
|
||||
token: string;
|
||||
@@ -9,7 +6,7 @@ export interface WargamingLogin {
|
||||
expires: number;
|
||||
}
|
||||
|
||||
interface AppStore {
|
||||
interface App {
|
||||
developerMode: boolean;
|
||||
policiesAgreementIndex: number;
|
||||
logins: {
|
||||
@@ -17,15 +14,11 @@ interface AppStore {
|
||||
};
|
||||
}
|
||||
|
||||
export const App = createContextualStore(() =>
|
||||
create<AppStore>()(
|
||||
persist(
|
||||
subscribeWithSelector<AppStore>(() => ({
|
||||
developerMode: false,
|
||||
policiesAgreementIndex: -1,
|
||||
logins: {},
|
||||
})),
|
||||
{ name: 'app', merge: (a, b) => merge(b, a) },
|
||||
),
|
||||
),
|
||||
export const App = new Varuna<App>(
|
||||
{
|
||||
developerMode: false,
|
||||
policiesAgreementIndex: -1,
|
||||
logins: {},
|
||||
},
|
||||
"app-2"
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
import type { Samples } from '@blitzkit/core';
|
||||
import { create } from 'zustand';
|
||||
import { createContextualStore } from '../core/zustand/createContextualStore';
|
||||
|
||||
export interface Charts {
|
||||
period: ChartsPeriod;
|
||||
}
|
||||
|
||||
export type ChartsPeriod = keyof Samples;
|
||||
|
||||
export const Charts = createContextualStore(() =>
|
||||
create<Charts>()(() => ({
|
||||
period: 'd_30',
|
||||
})),
|
||||
);
|
||||
@@ -2,16 +2,14 @@ import {
|
||||
ModelDefinition,
|
||||
type EngineDefinition,
|
||||
type GunDefinition,
|
||||
type ProvisionDefinitions,
|
||||
type ShellDefinition,
|
||||
type TankDefinition,
|
||||
type TrackDefinition,
|
||||
type TurretDefinition,
|
||||
} from '@blitzkit/core';
|
||||
import { create } from 'zustand';
|
||||
import { subscribeWithSelector } from 'zustand/middleware';
|
||||
import { tankToDuelMember } from '../../core/blitzkit/tankToDuelMember';
|
||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||
} from "@blitzkit/core";
|
||||
import { Varuna } from "varuna";
|
||||
import { awaitableProvisionDefinitions } from "../../core/awaitables/provisionDefinitions";
|
||||
import { tankToDuelMember } from "../../core/blitzkit/tankToDuelMember";
|
||||
|
||||
type EquipmentMatrixItem = -1 | 0 | 1;
|
||||
type EquipmentMatrixRow = [
|
||||
@@ -45,24 +43,13 @@ export interface DuelStore {
|
||||
antagonist: DuelMember;
|
||||
}
|
||||
|
||||
export const Duel = createContextualStore(
|
||||
({
|
||||
tank,
|
||||
model,
|
||||
provisionDefinitions,
|
||||
}: {
|
||||
tank: TankDefinition;
|
||||
model: ModelDefinition;
|
||||
provisionDefinitions: ProvisionDefinitions;
|
||||
}) => {
|
||||
const protagonist = tankToDuelMember(tank, provisionDefinitions);
|
||||
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||
|
||||
return create<DuelStore>()(
|
||||
subscribeWithSelector<DuelStore>(() => ({
|
||||
protagonist,
|
||||
model,
|
||||
antagonist: protagonist,
|
||||
})),
|
||||
);
|
||||
},
|
||||
);
|
||||
export const Duel = new Varuna<
|
||||
DuelStore,
|
||||
{ tank: TankDefinition; model: ModelDefinition }
|
||||
>(({ tank, model }) => {
|
||||
const protagonist = tankToDuelMember(tank, provisionDefinitions);
|
||||
|
||||
return { protagonist, antagonist: protagonist, model };
|
||||
});
|
||||
@@ -1,16 +1,15 @@
|
||||
import * as radixColors from '@radix-ui/colors';
|
||||
import { create } from 'zustand';
|
||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||
import * as radixColors from "@radix-ui/colors";
|
||||
import { Varuna } from "varuna";
|
||||
import {
|
||||
type EmbedConfigItemType,
|
||||
EmbedItemType,
|
||||
radixGrays,
|
||||
radixTextWeights,
|
||||
} from './constants';
|
||||
} from "./constants";
|
||||
|
||||
export type RadixSize = `${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
export type RadixSizeWithout0 = Exclude<RadixSize, '0'>;
|
||||
export type RadixRadius = `${1 | 2 | 3 | 4}` | 'full';
|
||||
export type RadixSizeWithout0 = Exclude<RadixSize, "0">;
|
||||
export type RadixRadius = `${1 | 2 | 3 | 4}` | "full";
|
||||
export type RadixTextWeight = (typeof radixTextWeights)[number];
|
||||
export type RadixColorCompound = {
|
||||
base: RadixColor;
|
||||
@@ -18,7 +17,7 @@ export type RadixColorCompound = {
|
||||
};
|
||||
export type RadixTextColor =
|
||||
| Exclude<RadixColor, RadixColorGrays>
|
||||
| 'gray'
|
||||
| "gray"
|
||||
| undefined;
|
||||
export type RadixColorVariantRaw = `${
|
||||
| 1
|
||||
@@ -33,17 +32,17 @@ export type RadixColorVariantRaw = `${
|
||||
| 10
|
||||
| 11
|
||||
| 12}`;
|
||||
export type RadixColorVariant = `${'' | 'a'}${RadixColorVariantRaw}`;
|
||||
export type RadixColorVariant = `${"" | "a"}${RadixColorVariantRaw}`;
|
||||
export type RadixColor = Exclude<
|
||||
keyof typeof radixColors,
|
||||
`${string}${'A' | 'P3' | 'Dark'}`
|
||||
`${string}${"A" | "P3" | "Dark"}`
|
||||
>;
|
||||
export type RadixColorGrays = (typeof radixGrays)[number];
|
||||
|
||||
export type ExtractEmbedConfigTypes<Config extends EmbedConfig> = {
|
||||
[Key in keyof Config]: ({
|
||||
type: Config[Key]['type'];
|
||||
} & EmbedConfigItem)['default'];
|
||||
type: Config[Key]["type"];
|
||||
} & EmbedConfigItem)["default"];
|
||||
};
|
||||
|
||||
export type EmbedConfig = {
|
||||
@@ -102,8 +101,8 @@ export type EmbedConfigItem = (
|
||||
pad?: boolean;
|
||||
};
|
||||
|
||||
export type EmbedStateStore = Record<string, EmbedConfigItem['default']>;
|
||||
export type EmbedStateStore = Record<string, EmbedConfigItem["default"]>;
|
||||
|
||||
export const EmbedState = createContextualStore((init: EmbedStateStore) =>
|
||||
create<EmbedStateStore>()(() => init),
|
||||
export const EmbedState = new Varuna<EmbedStateStore, EmbedStateStore>(
|
||||
(data) => data
|
||||
);
|
||||
@@ -1,6 +1,5 @@
|
||||
import type en from '@blitzkit/i18n/strings/en.json';
|
||||
import { create } from 'zustand';
|
||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||
import type en from "@blitzkit/i18n/strings/en.json";
|
||||
import { Varuna } from "varuna";
|
||||
|
||||
export type TankPerformanceSortType =
|
||||
keyof typeof en.website.tools.performance.table.stats;
|
||||
@@ -10,9 +9,7 @@ export interface TankPerformanceSort {
|
||||
direction: -1 | 1;
|
||||
}
|
||||
|
||||
export const TankPerformanceSort = createContextualStore(() =>
|
||||
create<TankPerformanceSort>()(() => ({
|
||||
type: 'winrate',
|
||||
direction: -1,
|
||||
})),
|
||||
);
|
||||
export const TankPerformanceSort = new Varuna<TankPerformanceSort>({
|
||||
type: "winrate",
|
||||
direction: -1,
|
||||
});
|
||||
@@ -1,14 +1,11 @@
|
||||
import type en from '@blitzkit/i18n/strings/en.json';
|
||||
import * as lodash from 'lodash-es';
|
||||
import { create } from 'zustand';
|
||||
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||
import type en from "@blitzkit/i18n/strings/en.json";
|
||||
import { Varuna } from "varuna";
|
||||
|
||||
export type TankopediaSortBy = keyof typeof en.website.common.tank_search.sort;
|
||||
export type TankopediaSortDirection = 'ascending' | 'descending';
|
||||
export type TankopediaTestTankDisplay = 'include' | 'exclude' | 'only';
|
||||
export type TankopediaSortDirection = "ascending" | "descending";
|
||||
export type TankopediaTestTankDisplay = "include" | "exclude" | "only";
|
||||
|
||||
export interface TankopediaPersistentStore {
|
||||
export interface TankopediaPersistent {
|
||||
wireframe: boolean;
|
||||
opaque: boolean;
|
||||
advancedHighlighting: boolean;
|
||||
@@ -25,25 +22,21 @@ export interface TankopediaPersistentStore {
|
||||
};
|
||||
}
|
||||
|
||||
export const TankopediaPersistent = createContextualStore(() =>
|
||||
create<TankopediaPersistentStore>()(
|
||||
persist(
|
||||
subscribeWithSelector<TankopediaPersistentStore>(() => ({
|
||||
hideTankModelUnderArmor: false,
|
||||
wireframe: false,
|
||||
opaque: false,
|
||||
advancedHighlighting: false,
|
||||
greenPenetration: false,
|
||||
showSpacedArmor: true,
|
||||
showExternalModules: true,
|
||||
showPrimaryArmor: true,
|
||||
recentlyViewed: [],
|
||||
sort: {
|
||||
by: 'meta.none',
|
||||
direction: 'ascending',
|
||||
},
|
||||
})),
|
||||
{ name: 'tankopedia', merge: (a, b) => lodash.merge(b, a) },
|
||||
),
|
||||
),
|
||||
export const TankopediaPersistent = new Varuna<TankopediaPersistent>(
|
||||
{
|
||||
hideTankModelUnderArmor: false,
|
||||
wireframe: false,
|
||||
opaque: false,
|
||||
advancedHighlighting: false,
|
||||
greenPenetration: false,
|
||||
showSpacedArmor: true,
|
||||
showExternalModules: true,
|
||||
showPrimaryArmor: true,
|
||||
recentlyViewed: [],
|
||||
sort: {
|
||||
by: "meta.none",
|
||||
direction: "ascending",
|
||||
},
|
||||
},
|
||||
"tankopedia-2"
|
||||
);
|
||||
Reference in new issue
Block a user