Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0929825555 | ||
|
|
4de0fc5ec1 | ||
|
|
e66610f86e | ||
|
|
674abc4923 | ||
|
|
25cee8a36b | ||
|
|
dcbac5e017 | ||
|
|
0c94d42f3f | ||
|
|
7ab5e94323 | ||
|
|
f9ea5ba74a | ||
|
|
1e7162d2da | ||
|
|
cfba53a655 | ||
|
|
77a85641f0 | ||
|
|
5330a27e96 | ||
|
|
a791aff4a0 | ||
|
|
df8a5967f0 | ||
|
|
6261dfc9cd | ||
|
|
766801826c | ||
|
|
7b728596ca | ||
|
|
0bf6ac33a5 | ||
|
|
9a33b84b1c | ||
|
|
c14efe86cc | ||
|
|
4ff9a2ec7f | ||
|
|
75d7b4554b | ||
|
|
27c8b348bb | ||
|
|
a55ab5e7ee | ||
|
|
12e90cc6ee | ||
|
|
01755a2a64 | ||
|
|
080f0a0eb7 | ||
|
|
a646cc1e57 | ||
|
|
d107813c37 | ||
|
|
27d3bbf346 | ||
|
|
50c77e0ae1 | ||
|
|
6e0429332d | ||
|
|
7afce6cbcb | ||
|
|
17c7a5c7f5 | ||
|
|
f5aa2ff9de | ||
|
|
96a8f225fc | ||
|
|
d15a5aee69 | ||
|
|
84dc5e4960 | ||
|
|
58b5ee7f83 | ||
|
|
8a99d34af9 | ||
|
|
7cd7bd83dc | ||
|
|
7d3b6221d7 | ||
|
|
fd66f9ab17 | ||
|
|
6fbb0e81cb | ||
|
|
6dc82588c1 | ||
|
|
c6eae9ad51 |
No files matched your search
@@ -24,7 +24,8 @@ public/sitemap*
|
||||
target
|
||||
# packages/core/src/protos/*.ts
|
||||
/.vercel
|
||||
/.astro
|
||||
.astro
|
||||
.vercel
|
||||
/src
|
||||
/packages/bot/src/prisma
|
||||
/packages/bot/src/prisma
|
||||
dev-dist
|
||||
@@ -21,6 +21,7 @@
|
||||
"AYUV",
|
||||
"battleresults",
|
||||
"bbox",
|
||||
"beforeinstallprompt",
|
||||
"bepaint",
|
||||
"betakrieg",
|
||||
"BINORMAL",
|
||||
@@ -76,7 +77,9 @@
|
||||
"echarts",
|
||||
"Everytime",
|
||||
"FASTNAME",
|
||||
"favicons",
|
||||
"flexdirection",
|
||||
"fontsource",
|
||||
"FOURCC",
|
||||
"frameloop",
|
||||
"fsformat",
|
||||
@@ -154,6 +157,7 @@
|
||||
"Pyogenics",
|
||||
"ratingleaderboard",
|
||||
"raycaster",
|
||||
"Redirector",
|
||||
"researchable",
|
||||
"Resvg",
|
||||
"rizz",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# BlitzKit 1.28.0
|
||||
|
||||
BlitzKit, as an app and the new Mixer tool!
|
||||
|
||||
## Features
|
||||
|
||||
- Created the BlitzKit app that can be downloaded on most devices
|
||||
- Re-did the BlitzKit logo to be a bit warmer
|
||||
- Added the Mixer tool which lets you combine tank models into Frankensteins
|
||||
- Updated all dependencies to the latest version for a decent performance boost
|
||||
|
||||
## Fixes
|
||||
|
||||
- BlitzKit no longer forgets persistent data if the app crashes without properly closing
|
||||
- The tools list in the navbar no longer overflows into the neighboring elements on certain devices
|
||||
- Added keying to a few places, speeding up re-rendering
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "blitzkit",
|
||||
"private": true,
|
||||
"version": "1.27.20",
|
||||
"version": "1.28.0",
|
||||
"description": "🎉 Tools for everything World of Tanks Blitz",
|
||||
"type": "module",
|
||||
"types": "./types.d.ts",
|
||||
@@ -16,6 +16,7 @@
|
||||
"build:prisma": "prisma generate",
|
||||
"build:sitemap": "bun scripts/sitemap.ts",
|
||||
"build:docs": "vitepress build docs",
|
||||
"build:proxyclient": "cd packages/scripts && bun run build:proxyclient",
|
||||
"build:ratingleaderboard": "cd packages/scripts && bun run build:ratingleaderboard",
|
||||
"dev:bot": "bun run build:bot --dev && bun start:bot",
|
||||
"start:bot": "bun dist/bot/main.js",
|
||||
@@ -41,19 +42,22 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/xmpp__client": "^0.13.3",
|
||||
"@xmpp/client": "^0.13.6",
|
||||
"astro-favicons": "^3.1.5",
|
||||
"cheerio": "^1.1.2",
|
||||
"googleapis": "^144.0.0",
|
||||
"googleapis": "^160.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"protobufjs": "^7.5.2",
|
||||
"protobufjs": "^7.5.4",
|
||||
"quicklime": "^1.2.0",
|
||||
"sharp": "^0.33.5"
|
||||
"sharp": "^0.34.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/bun": "^1.2.22",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^22.14.1",
|
||||
"prettier": "^3.5.3",
|
||||
"prisma": "^6.6.0",
|
||||
"typescript": "^5.8.3"
|
||||
"@types/node": "^24.5.2",
|
||||
"prettier": "^3.6.2",
|
||||
"prisma": "^6.16.2",
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
"dependencies": {
|
||||
"@blitzkit/core": "workspace:*",
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"satori": "^0.10.14",
|
||||
"satori": "^0.18.3",
|
||||
"@resvg/resvg-js": "^2.6.2",
|
||||
"discord.js": "^14.16.3",
|
||||
"react": "^18.3.1",
|
||||
"discord.js": "^14.22.1",
|
||||
"react": "^19.1.1",
|
||||
"@radix-ui/colors": "^3.0.0",
|
||||
"fuzzysort": "^2.0.4",
|
||||
"fuzzysort": "^3.1.0",
|
||||
"bepaint": "^0.1.0-beta.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"dotenv": "^17.2.2",
|
||||
"markdown-escape": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -6,23 +6,23 @@ import {
|
||||
getTankStats,
|
||||
getWN8Percentile,
|
||||
TankDefinition,
|
||||
} from '@blitzkit/core';
|
||||
import { literals } from '@blitzkit/i18n';
|
||||
import { Locale } from 'discord.js';
|
||||
import { chunk } from 'lodash-es';
|
||||
import * as Breakdown from '../../components/Breakdown';
|
||||
import { CommandWrapper } from '../../components/CommandWrapper';
|
||||
import { NoData } from '../../components/NoData';
|
||||
import { TitleBar } from '../../components/TitleBar';
|
||||
import { filtersToDescription } from '../../core/blitzkit/filtersToDescription';
|
||||
import { tankDefinitions } from '../../core/blitzkit/nonBlockingPromises';
|
||||
import { UserError } from '../../core/blitzkit/userError';
|
||||
import { filterStats, StatFilters } from '../../core/blitzstars/filterStats';
|
||||
import { getStatsInPeriod } from '../../core/blitzstars/getStatsInPeriod';
|
||||
import { blitzStarsTankAverages } from '../../core/blitzstars/tankAverages';
|
||||
import { ResolvedPeriod } from '../../core/discord/resolvePeriodFromCommand';
|
||||
import { ResolvedPlayer } from '../../core/discord/resolvePlayerFromCommand';
|
||||
import { translator } from '../../core/localization/translator';
|
||||
} from "@blitzkit/core";
|
||||
import { literals } from "@blitzkit/i18n";
|
||||
import { Locale } from "discord.js";
|
||||
import { chunk } from "lodash-es";
|
||||
import * as Breakdown from "../../components/Breakdown";
|
||||
import { CommandWrapper } from "../../components/CommandWrapper";
|
||||
import { NoData } from "../../components/NoData";
|
||||
import { TitleBar } from "../../components/TitleBar";
|
||||
import { filtersToDescription } from "../../core/blitzkit/filtersToDescription";
|
||||
import { tankDefinitions } from "../../core/blitzkit/nonBlockingPromises";
|
||||
import { UserError } from "../../core/blitzkit/userError";
|
||||
import { filterStats, StatFilters } from "../../core/blitzstars/filterStats";
|
||||
import { getStatsInPeriod } from "../../core/blitzstars/getStatsInPeriod";
|
||||
import { blitzStarsTankAverages } from "../../core/blitzstars/tankAverages";
|
||||
import { ResolvedPeriod } from "../../core/discord/resolvePeriodFromCommand";
|
||||
import { ResolvedPlayer } from "../../core/discord/resolvePlayerFromCommand";
|
||||
import { translator } from "../../core/localization/translator";
|
||||
|
||||
const ROWS_PER_PAGE = 8;
|
||||
const MAX_PAGES = 9;
|
||||
@@ -31,7 +31,7 @@ export async function renderBreakdown(
|
||||
{ region, id }: ResolvedPlayer,
|
||||
{ start, end, name }: ResolvedPeriod,
|
||||
filters: StatFilters,
|
||||
locale: Locale,
|
||||
locale: Locale
|
||||
) {
|
||||
const { strings, unwrap } = translator(locale);
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
@@ -39,7 +39,7 @@ export async function renderBreakdown(
|
||||
const statsInPeriod = await getStatsInPeriod(region, id, start, end, locale);
|
||||
const { filteredOrder } = await filterStats(statsInPeriod, filters);
|
||||
const accountInfo = await getAccountInfo(region, id);
|
||||
const clanData = await getClanAccountInfo(region, id, ['clan']);
|
||||
const clanData = await getClanAccountInfo(region, id, ["clan"]);
|
||||
const tankStats = await getTankStats(region, id);
|
||||
const filterDescriptions = await filtersToDescription(filters, locale);
|
||||
const orderedCurrentStats: BlitzStats[] = [];
|
||||
@@ -74,63 +74,63 @@ export async function renderBreakdown(
|
||||
orderedCareerWN8Full.push(
|
||||
tankAveragesEntry
|
||||
? calculateWN8(tankAveragesEntry.all, tank.all)
|
||||
: undefined,
|
||||
: undefined
|
||||
);
|
||||
});
|
||||
|
||||
const currentBattles = orderedCurrentStats.reduce(
|
||||
(accumulator, current) => accumulator + current.battles,
|
||||
0,
|
||||
0
|
||||
);
|
||||
const careerBattles = tankStats.reduce(
|
||||
(accumulator, current) => accumulator + current.all.battles,
|
||||
0,
|
||||
0
|
||||
);
|
||||
const currentWinrate =
|
||||
orderedCurrentStats.reduce(
|
||||
(accumulator, current) => accumulator + current.wins,
|
||||
0,
|
||||
0
|
||||
) / currentBattles;
|
||||
const careerWinrate =
|
||||
tankStats.reduce(
|
||||
(accumulator, current) => accumulator + current.all.wins,
|
||||
0,
|
||||
0
|
||||
) / careerBattles;
|
||||
const currentWN8 =
|
||||
orderedCurrentWN8.reduce<number>(
|
||||
(accumulator, current, index) =>
|
||||
accumulator + (current ?? 0) * orderedCurrentStats[index].battles,
|
||||
0,
|
||||
0
|
||||
) /
|
||||
orderedCurrentStats.reduce(
|
||||
(accumulator, current, index) =>
|
||||
accumulator +
|
||||
(orderedCurrentWN8[index] === undefined ? 0 : current.battles),
|
||||
0,
|
||||
0
|
||||
);
|
||||
const careerWN8 =
|
||||
orderedCareerWN8Full.reduce<number>(
|
||||
(accumulator, current) => accumulator + (current ?? 0),
|
||||
0,
|
||||
0
|
||||
) /
|
||||
tankStats.reduce(
|
||||
(accumulator, current, index) =>
|
||||
accumulator +
|
||||
(orderedCareerWN8Full[index] === undefined ? 0 : current.all.battles),
|
||||
0,
|
||||
0
|
||||
);
|
||||
const currentDamage =
|
||||
orderedCurrentStats.reduce(
|
||||
(accumulator, current) => accumulator + current.damage_dealt,
|
||||
0,
|
||||
0
|
||||
) / currentBattles;
|
||||
const careerDamage =
|
||||
tankStats.reduce(
|
||||
(accumulator, current) => accumulator + current.all.damage_dealt,
|
||||
0,
|
||||
0
|
||||
) / careerBattles;
|
||||
|
||||
const children: JSX.Element[] = [];
|
||||
const children: React.JSX.Element[] = [];
|
||||
|
||||
if (filteredOrder.length > 0) {
|
||||
children.push(
|
||||
@@ -172,7 +172,7 @@ export async function renderBreakdown(
|
||||
delta: currentDamage - careerDamage,
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
/>
|
||||
);
|
||||
|
||||
filteredOrder.forEach((id, index) => {
|
||||
@@ -206,7 +206,7 @@ export async function renderBreakdown(
|
||||
{
|
||||
title: strings.bot.commands.breakdown.body.winrate,
|
||||
current: `${(100 * (current.wins / current.battles)).toFixed(
|
||||
2,
|
||||
2
|
||||
)}%`,
|
||||
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
||||
delta:
|
||||
@@ -230,24 +230,24 @@ export async function renderBreakdown(
|
||||
{
|
||||
title: strings.bot.commands.breakdown.body.damage,
|
||||
current: Math.round(
|
||||
current.damage_dealt / current.battles,
|
||||
current.damage_dealt / current.battles
|
||||
).toLocaleString(),
|
||||
career: Math.round(
|
||||
career.damage_dealt / career.battles,
|
||||
career.damage_dealt / career.battles
|
||||
).toLocaleString(),
|
||||
delta:
|
||||
current.damage_dealt / current.battles -
|
||||
career.damage_dealt / career.battles,
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
/>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const pages = chunk(
|
||||
children,
|
||||
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE),
|
||||
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE)
|
||||
);
|
||||
|
||||
if (filteredOrder.length > 0) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { jsxToSvg } from './jsxToSvg';
|
||||
import { svgToPng } from './svgToPng';
|
||||
import { jsxToSvg } from "./jsxToSvg";
|
||||
import { svgToPng } from "./svgToPng";
|
||||
|
||||
export async function jsxToPng(jsx: JSX.Element) {
|
||||
export async function jsxToPng(jsx: React.JSX.Element) {
|
||||
const svg = await jsxToSvg(jsx);
|
||||
const png = svgToPng(svg);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { jsxToSvg } from './jsxToSvg';
|
||||
import { RenderConfiguration } from './renderConfiguration';
|
||||
import { svgToPngThreaded } from './svgToPngThreaded';
|
||||
import { jsxToSvg } from "./jsxToSvg";
|
||||
import { RenderConfiguration } from "./renderConfiguration";
|
||||
import { svgToPngThreaded } from "./svgToPngThreaded";
|
||||
|
||||
export async function jsxToPngThreaded(
|
||||
jsx: JSX.Element,
|
||||
renderConfiguration: RenderConfiguration,
|
||||
jsx: React.JSX.Element,
|
||||
renderConfiguration: RenderConfiguration
|
||||
) {
|
||||
const svg = await jsxToSvg(jsx, renderConfiguration);
|
||||
const png = await svgToPngThreaded(svg);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { readFile } from 'fs/promises';
|
||||
import satori from 'satori';
|
||||
import { RenderConfiguration } from '../renderConfiguration';
|
||||
import robotoBlack from './Roboto-Black.ttf';
|
||||
import robotoBold from './Roboto-Bold.ttf';
|
||||
import roboto from './Roboto.ttf';
|
||||
import { readFile } from "fs/promises";
|
||||
import satori from "satori";
|
||||
import { RenderConfiguration } from "../renderConfiguration";
|
||||
import robotoBlack from "./Roboto-Black.ttf";
|
||||
import robotoBold from "./Roboto-Bold.ttf";
|
||||
import roboto from "./Roboto.ttf";
|
||||
|
||||
const fontsPromise = [
|
||||
{ file: roboto, weight: 400 as const },
|
||||
@@ -11,12 +11,12 @@ const fontsPromise = [
|
||||
{ file: robotoBlack, weight: 900 as const },
|
||||
].map(async ({ file, weight }) => {
|
||||
const data = await readFile(`${__dirname}/${file}`);
|
||||
return { name: 'Roboto', weight, data };
|
||||
return { name: "Roboto", weight, data };
|
||||
});
|
||||
|
||||
export async function jsxToSvg(
|
||||
jsx: JSX.Element,
|
||||
renderConfiguration = new RenderConfiguration(),
|
||||
jsx: React.JSX.Element,
|
||||
renderConfiguration = new RenderConfiguration()
|
||||
) {
|
||||
const fonts = await Promise.all(fontsPromise);
|
||||
return await satori(jsx, { width: renderConfiguration.width, fonts });
|
||||
|
||||
@@ -6,14 +6,14 @@ import {
|
||||
InteractionEditReplyOptions,
|
||||
InteractionReplyOptions,
|
||||
MessageEditOptions,
|
||||
} from 'discord.js';
|
||||
import { InteractionReturnable } from '../../events/interactionCreate';
|
||||
import { Writeable } from '../../types/writable';
|
||||
import { jsxToPngThreaded } from '../blitzkit/jsxToPngThreaded';
|
||||
import { RenderConfiguration } from '../blitzkit/renderConfiguration';
|
||||
} from "discord.js";
|
||||
import { InteractionReturnable } from "../../events/interactionCreate";
|
||||
import { Writeable } from "../../types/writable";
|
||||
import { jsxToPngThreaded } from "../blitzkit/jsxToPngThreaded";
|
||||
import { RenderConfiguration } from "../blitzkit/renderConfiguration";
|
||||
|
||||
export async function normalizeInteractionReturnable(
|
||||
returnable: InteractionReturnable,
|
||||
returnable: InteractionReturnable
|
||||
) {
|
||||
const images: [number, Buffer][] = [];
|
||||
const reply: InteractionEditReplyOptions &
|
||||
@@ -27,7 +27,7 @@ export async function normalizeInteractionReturnable(
|
||||
|
||||
await Promise.all(
|
||||
normalizedReturnable.map(async (item, index) => {
|
||||
if (typeof item === 'string') {
|
||||
if (typeof item === "string") {
|
||||
reply.content = item;
|
||||
} else if (item instanceof EmbedBuilder) {
|
||||
if (!reply.embeds) reply.embeds = [];
|
||||
@@ -36,7 +36,7 @@ export async function normalizeInteractionReturnable(
|
||||
if (!reply.components)
|
||||
reply.components = [new ActionRowBuilder<ButtonBuilder>()];
|
||||
(reply.components[0] as ActionRowBuilder<ButtonBuilder>).addComponents(
|
||||
item,
|
||||
item
|
||||
);
|
||||
} else if (item instanceof AttachmentBuilder) {
|
||||
if (!reply.files) reply.files = [];
|
||||
@@ -49,14 +49,14 @@ export async function normalizeInteractionReturnable(
|
||||
const image = await jsxToPngThreaded(item, renderConfiguration);
|
||||
images.push([index, image]);
|
||||
}
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
if (images.length > 0) {
|
||||
images.sort(([a], [b]) => b - a);
|
||||
if (!reply.files) reply.files = [];
|
||||
images.forEach(([, image]) =>
|
||||
(reply.files as Writeable<typeof reply.files>)?.push(image),
|
||||
(reply.files as Writeable<typeof reply.files>)?.push(image)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DEFAULT_LOCALE, SupportedLocale } from '@blitzkit/i18n';
|
||||
import { Locale } from 'discord.js';
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { Locale } from "discord.js";
|
||||
|
||||
const SUPPORTED_LOCALES_DISCORD_MAP: Record<SupportedLocale, Locale> = {
|
||||
const SUPPORTED_LOCALES_DISCORD_MAP: Record<string, Locale> = {
|
||||
en: Locale.EnglishUS,
|
||||
es: Locale.SpanishES,
|
||||
pt: Locale.PortugueseBR,
|
||||
@@ -14,12 +14,12 @@ const SUPPORTED_LOCALES_DISCORD_MAP: Record<SupportedLocale, Locale> = {
|
||||
};
|
||||
|
||||
export const SUPPORTED_LOCALES_DISCORD_MAP_INVERSE = Object.fromEntries(
|
||||
Object.entries(SUPPORTED_LOCALES_DISCORD_MAP).map(([k, v]) => [v, k]),
|
||||
) as Record<Locale, SupportedLocale>;
|
||||
Object.entries(SUPPORTED_LOCALES_DISCORD_MAP).map(([k, v]) => [v, k])
|
||||
) as Record<Locale, string>;
|
||||
|
||||
export const SUPPORTED_LOCALES_DISCORD = Object.values(
|
||||
SUPPORTED_LOCALES_DISCORD_MAP,
|
||||
SUPPORTED_LOCALES_DISCORD_MAP
|
||||
);
|
||||
|
||||
export const DEFAULT_LOCALE_DISCORD =
|
||||
SUPPORTED_LOCALES_DISCORD_MAP[DEFAULT_LOCALE];
|
||||
SUPPORTED_LOCALES_DISCORD_MAP[locales.default];
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import {
|
||||
AttachmentBuilder,
|
||||
AutocompleteInteraction,
|
||||
@@ -13,30 +13,30 @@ import {
|
||||
SlashCommandBuilder,
|
||||
SlashCommandOptionsOnlyBuilder,
|
||||
SlashCommandSubcommandsOnlyBuilder,
|
||||
} from 'discord.js';
|
||||
import { aboutCommand } from '../../commands/about';
|
||||
import { breakdownCommand } from '../../commands/breakdown';
|
||||
import { debugCommand } from '../../commands/debug';
|
||||
import { evolutionCommand } from '../../commands/evolution';
|
||||
import { fullStatsCommand } from '../../commands/fullStats';
|
||||
import { inactiveCommand } from '../../commands/inactive';
|
||||
import { verifyCommand } from '../../commands/link';
|
||||
import { ownedTanksCommand } from '../../commands/ownedTanks';
|
||||
import { permissionsCommand } from '../../commands/permissions';
|
||||
import { pingCommand } from '../../commands/ping';
|
||||
import { playerInfoCommand } from '../../commands/playerInfo';
|
||||
import { ratingCommand } from '../../commands/rating';
|
||||
import { ratingLeaderboardCommand } from '../../commands/ratingLeaderboard';
|
||||
import { replayCommand } from '../../commands/replay';
|
||||
import { researchCommand } from '../../commands/research';
|
||||
import { searchClansCommand } from '../../commands/searchClans';
|
||||
import { searchPlayersCommand } from '../../commands/searchPlayers';
|
||||
import { statsCommand } from '../../commands/stats';
|
||||
import { todayCommand } from '../../commands/today';
|
||||
import { RenderConfiguration } from '../../core/blitzkit/renderConfiguration';
|
||||
import { handleAutocomplete } from './handlers/autocomplete';
|
||||
import { handleButton } from './handlers/button';
|
||||
import { handleChatInputCommand } from './handlers/chatInputCommand';
|
||||
} from "discord.js";
|
||||
import { aboutCommand } from "../../commands/about";
|
||||
import { breakdownCommand } from "../../commands/breakdown";
|
||||
import { debugCommand } from "../../commands/debug";
|
||||
import { evolutionCommand } from "../../commands/evolution";
|
||||
import { fullStatsCommand } from "../../commands/fullStats";
|
||||
import { inactiveCommand } from "../../commands/inactive";
|
||||
import { verifyCommand } from "../../commands/link";
|
||||
import { ownedTanksCommand } from "../../commands/ownedTanks";
|
||||
import { permissionsCommand } from "../../commands/permissions";
|
||||
import { pingCommand } from "../../commands/ping";
|
||||
import { playerInfoCommand } from "../../commands/playerInfo";
|
||||
import { ratingCommand } from "../../commands/rating";
|
||||
import { ratingLeaderboardCommand } from "../../commands/ratingLeaderboard";
|
||||
import { replayCommand } from "../../commands/replay";
|
||||
import { researchCommand } from "../../commands/research";
|
||||
import { searchClansCommand } from "../../commands/searchClans";
|
||||
import { searchPlayersCommand } from "../../commands/searchPlayers";
|
||||
import { statsCommand } from "../../commands/stats";
|
||||
import { todayCommand } from "../../commands/today";
|
||||
import { RenderConfiguration } from "../../core/blitzkit/renderConfiguration";
|
||||
import { handleAutocomplete } from "./handlers/autocomplete";
|
||||
import { handleButton } from "./handlers/button";
|
||||
import { handleChatInputCommand } from "./handlers/chatInputCommand";
|
||||
|
||||
export type InteractionRawReturnable =
|
||||
| string
|
||||
@@ -44,7 +44,7 @@ export type InteractionRawReturnable =
|
||||
| ButtonBuilder
|
||||
| AttachmentBuilder
|
||||
| RenderConfiguration
|
||||
| JSX.Element
|
||||
| React.JSX.Element
|
||||
| null;
|
||||
export type InteractionIterableReturnable =
|
||||
| InteractionRawReturnable
|
||||
@@ -58,7 +58,7 @@ interface CommandRegistryBase {
|
||||
| SlashCommandBuilder
|
||||
| SlashCommandSubcommandsOnlyBuilder
|
||||
| SlashCommandOptionsOnlyBuilder
|
||||
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||
| Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
|
||||
|
||||
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
||||
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
||||
@@ -72,7 +72,7 @@ interface CommandRegistryImplicit extends CommandRegistryBase {
|
||||
interface CommandRegistryExplicit extends CommandRegistryBase {
|
||||
handlesInteraction?: false;
|
||||
handler: (
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
interaction: ChatInputCommandInteraction<CacheType>
|
||||
) => InteractionReturnable;
|
||||
}
|
||||
|
||||
@@ -104,16 +104,16 @@ export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
||||
export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
|
||||
return rawCommands.reduce<Record<string, CommandRegistry>>(
|
||||
(commands, registry, index) => {
|
||||
if (registry.status === 'rejected') {
|
||||
if (registry.status === "rejected") {
|
||||
console.warn(
|
||||
`Command ${index} failed to load; skipping...`,
|
||||
registry.reason,
|
||||
registry.reason
|
||||
);
|
||||
return commands;
|
||||
}
|
||||
return { ...commands, [registry.value.command.name]: registry.value };
|
||||
},
|
||||
{},
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -121,12 +121,12 @@ const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
|
||||
|
||||
commands.then((awaitedCommands) => {
|
||||
const body = Object.values(awaitedCommands).map((registry) =>
|
||||
registry.command.toJSON(),
|
||||
registry.command.toJSON()
|
||||
);
|
||||
|
||||
rest.put(
|
||||
Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
|
||||
{ body },
|
||||
{ body }
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"dependencies": {
|
||||
"@octokit/plugin-throttling": "^8.2.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
"@prisma/client": "^6.6.0",
|
||||
"@octokit/plugin-throttling": "^11.0.1",
|
||||
"@octokit/rest": "^22.0.0",
|
||||
"@prisma/client": "^6.16.2",
|
||||
"adm-zip": "^0.5.16",
|
||||
"crc": "^4.3.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"dotenv": "^17.2.2",
|
||||
"lz4js": "^0.2.0",
|
||||
"pickleparser": "^0.2.1",
|
||||
"protobufjs": "^7.4.0",
|
||||
"ts-proto": "^2.2.2",
|
||||
"yaml": "^2.5.0"
|
||||
"protobufjs": "^7.5.4",
|
||||
"ts-proto": "^2.7.7",
|
||||
"yaml": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.5.5",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/lz4js": "^0.2.1"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { deburr } from 'lodash-es';
|
||||
import { SUPPORTED_LOCALES } from '../../../i18n/src/strings';
|
||||
import { I18nString } from '../protos';
|
||||
import { fetchCamouflageDefinitions } from './camouflageDefinitions';
|
||||
import { fetchTankDefinitions } from './tankDefinitions';
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { deburr } from "lodash-es";
|
||||
import { I18nString } from "../protos";
|
||||
import { fetchCamouflageDefinitions } from "./camouflageDefinitions";
|
||||
import { fetchTankDefinitions } from "./tankDefinitions";
|
||||
|
||||
export async function fetchTankNames() {
|
||||
const [tankDefinitions, camouflageDefinitions] = await Promise.all([
|
||||
@@ -26,25 +26,27 @@ export async function fetchTankNames() {
|
||||
searchableNameDeburr,
|
||||
camouflages: tank.camouflages
|
||||
?.map((id) =>
|
||||
SUPPORTED_LOCALES.map(
|
||||
(locale) =>
|
||||
camouflageDefinitions.camouflages[id]?.name.locales[locale],
|
||||
),
|
||||
locales.supported.map(
|
||||
({ locale }) =>
|
||||
camouflageDefinitions.camouflages[id]?.name.locales[locale]
|
||||
)
|
||||
)
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.map(deburr)
|
||||
.join(' '),
|
||||
.join(" "),
|
||||
treeType: tank.type,
|
||||
};
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export const SEARCH_KEYS = [
|
||||
...SUPPORTED_LOCALES.map((locale) => [
|
||||
`searchableName.locales.${locale}`,
|
||||
`searchableNameDeburr.locales.${locale}`,
|
||||
]).flat(),
|
||||
'camouflages',
|
||||
...locales.supported
|
||||
.map(({ locale }) => [
|
||||
`searchableName.locales.${locale}`,
|
||||
`searchableNameDeburr.locales.${locale}`,
|
||||
])
|
||||
.flat(),
|
||||
"camouflages",
|
||||
];
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"dependencies": {
|
||||
"ts-deepmerge": "^7.0.2"
|
||||
"ts-deepmerge": "^7.0.3"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './literals';
|
||||
export * from './strings';
|
||||
export * from './unwrapper';
|
||||
export * from "./literals";
|
||||
export * from "./strings";
|
||||
export * from "./unwrapper";
|
||||
export * from "./wrapper";
|
||||
@@ -1,98 +1,66 @@
|
||||
import { merge } from 'ts-deepmerge';
|
||||
import en from '../strings/en.json';
|
||||
import es from '../strings/es.json';
|
||||
import fr from '../strings/fr.json';
|
||||
import ja from '../strings/ja.json';
|
||||
import pl from '../strings/pl.json';
|
||||
import pt from '../strings/pt.json';
|
||||
import ru from '../strings/ru.json';
|
||||
import uk from '../strings/uk.json';
|
||||
import zh from '../strings/zh.json';
|
||||
import { merge } from "ts-deepmerge";
|
||||
import locales from "../locales.json";
|
||||
import en from "../strings/en.json";
|
||||
import es from "../strings/es.json";
|
||||
import fr from "../strings/fr.json";
|
||||
import ja from "../strings/ja.json";
|
||||
import pl from "../strings/pl.json";
|
||||
import pt from "../strings/pt.json";
|
||||
import ru from "../strings/ru.json";
|
||||
import uk from "../strings/uk.json";
|
||||
import zh from "../strings/zh.json";
|
||||
|
||||
export type BlitzKitStrings = typeof en;
|
||||
|
||||
const stringsRaw = { en, es, fr, ja, pl, pt, ru, uk, zh };
|
||||
const stringsRaw: Record<string, TranslationTree> = {
|
||||
en,
|
||||
es,
|
||||
fr,
|
||||
ja,
|
||||
pl,
|
||||
pt,
|
||||
ru,
|
||||
uk,
|
||||
zh,
|
||||
};
|
||||
|
||||
export const SUPPORTED_LOCALES = Object.keys(stringsRaw) as SupportedLocale[];
|
||||
|
||||
export const DEFAULT_LOCALE = SUPPORTED_LOCALES[0];
|
||||
|
||||
function redact(string: string) {
|
||||
const matches = [...string.matchAll(/%s\d+/g)];
|
||||
const characters = string
|
||||
.split('')
|
||||
.map((char) => (char === ' ' ? ' ' : '█')) as string[];
|
||||
|
||||
matches.forEach((match) => {
|
||||
const start = match.index;
|
||||
const matchText = match[0];
|
||||
for (let i = 0; i < matchText.length; i++) {
|
||||
characters[start + i] = matchText[i];
|
||||
}
|
||||
});
|
||||
|
||||
return characters.join('');
|
||||
}
|
||||
|
||||
function nuke(object: TranslationTree) {
|
||||
for (const key in object) {
|
||||
const typedKey = key as keyof typeof object;
|
||||
|
||||
if (typeof object[typedKey] === 'string') {
|
||||
const value = object[typedKey];
|
||||
object[typedKey] = redact(value as string);
|
||||
} else nuke(object[typedKey] as TranslationTree);
|
||||
}
|
||||
}
|
||||
|
||||
const stringsPartial: Partial<Record<SupportedLocale, TranslationTree>> = {};
|
||||
export const STRINGS: Record<string, BlitzKitStrings> = {};
|
||||
|
||||
for (const locale in stringsRaw) {
|
||||
if (locale === DEFAULT_LOCALE) {
|
||||
stringsPartial[DEFAULT_LOCALE] = stringsRaw[DEFAULT_LOCALE];
|
||||
if (locale === locales.default) {
|
||||
STRINGS[locales.default] = stringsRaw[locales.default] as BlitzKitStrings;
|
||||
continue;
|
||||
}
|
||||
|
||||
const localeStrings = stringsRaw[locale as SupportedLocale];
|
||||
stringsPartial[locale as SupportedLocale] = merge(
|
||||
stringsRaw[DEFAULT_LOCALE],
|
||||
localeStrings,
|
||||
);
|
||||
|
||||
if (import.meta.env.PUBLIC_DEBUG_MISSING_I18N === 'true') {
|
||||
nuke(stringsPartial[locale as SupportedLocale]!);
|
||||
}
|
||||
const localeStrings = stringsRaw[locale];
|
||||
STRINGS[locale] = merge(
|
||||
stringsRaw[locales.default],
|
||||
localeStrings
|
||||
) as BlitzKitStrings;
|
||||
}
|
||||
|
||||
export const STRINGS = stringsPartial as Record<
|
||||
SupportedLocale,
|
||||
BlitzKitStrings
|
||||
>;
|
||||
|
||||
export type SupportedLocale = keyof typeof stringsRaw;
|
||||
|
||||
export const SUPPORTED_LOCALE_BLITZ_MAP: Record<SupportedLocale, string> = {
|
||||
en: 'en',
|
||||
es: 'es',
|
||||
fr: 'fr',
|
||||
ja: 'ja',
|
||||
pt: 'pt',
|
||||
ru: 'ru',
|
||||
uk: 'uk',
|
||||
zh: 'zh-Hans',
|
||||
pl: 'pl',
|
||||
export const SUPPORTED_LOCALE_BLITZ_MAP: Record<string, string> = {
|
||||
en: "en",
|
||||
es: "es",
|
||||
fr: "fr",
|
||||
ja: "ja",
|
||||
pt: "pt",
|
||||
ru: "ru",
|
||||
uk: "uk",
|
||||
zh: "zh-Hans",
|
||||
pl: "pl",
|
||||
};
|
||||
|
||||
export const SUPPORTED_LOCALE_FLAGS: Record<SupportedLocale, string> = {
|
||||
en: '🇺🇸',
|
||||
es: '🇪🇸',
|
||||
fr: '🇫🇷',
|
||||
ja: '🇯🇵',
|
||||
pt: '🇵🇹',
|
||||
ru: '🇷🇺',
|
||||
uk: '🇺🇦',
|
||||
zh: '🇨🇳',
|
||||
pl: '🇵🇱',
|
||||
export const SUPPORTED_LOCALE_FLAGS: Record<string, string> = {
|
||||
en: "🇺🇸",
|
||||
es: "🇪🇸",
|
||||
fr: "🇫🇷",
|
||||
ja: "🇯🇵",
|
||||
pt: "🇵🇹",
|
||||
ru: "🇷🇺",
|
||||
uk: "🇺🇦",
|
||||
zh: "🇨🇳",
|
||||
pl: "🇵🇱",
|
||||
};
|
||||
|
||||
export type TranslationTree = { [key: string]: TranslationNode };
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { I18nString } from '@blitzkit/core';
|
||||
import { DEFAULT_LOCALE } from './strings';
|
||||
import { I18nString } from "@blitzkit/core";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
|
||||
export function unwrapper(locale: string) {
|
||||
export function unwrapper(locale = locales.default) {
|
||||
return function (i18nString: I18nString) {
|
||||
if (locale in i18nString.locales) {
|
||||
return i18nString.locales[locale];
|
||||
}
|
||||
|
||||
return i18nString.locales[DEFAULT_LOCALE];
|
||||
return i18nString.locales[locales.default];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import locales from "../locales.json";
|
||||
import { BlitzKitStrings, STRINGS } from "./strings";
|
||||
|
||||
export function wrapper(slicer: (strings: BlitzKitStrings) => string) {
|
||||
const defaultString = slicer(STRINGS[locales.default] as BlitzKitStrings);
|
||||
|
||||
const object = { [locales.default]: defaultString };
|
||||
|
||||
for (const { locale } of locales.supported) {
|
||||
const string = slicer(STRINGS[locale] as BlitzKitStrings);
|
||||
if (string !== defaultString) object[locale] = string;
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
},
|
||||
|
||||
"common": {
|
||||
"name": "BlitzKit",
|
||||
|
||||
"units": {
|
||||
"m": "%s1m",
|
||||
"mm": "%s1mm",
|
||||
@@ -763,6 +765,8 @@
|
||||
},
|
||||
|
||||
"tank_search": {
|
||||
"select_dialog_title": "Search for tanks",
|
||||
"swap_dialog_title": "Swap tank",
|
||||
"clear_filters": "Clear filters",
|
||||
"search_bar_hint": "Search tanks...",
|
||||
"recent": "Recently viewed",
|
||||
@@ -833,6 +837,15 @@
|
||||
},
|
||||
|
||||
"home": {
|
||||
"pwa": {
|
||||
"title": "Install the BlitzKit App",
|
||||
"new": "NEW",
|
||||
"checking": "Checking compatibility...",
|
||||
"instructions": "Instructions for Apple devices.",
|
||||
"install": "Install",
|
||||
"dismiss": "Dismiss"
|
||||
},
|
||||
|
||||
"discord": {
|
||||
"join_short": "Join cool people!",
|
||||
"join_long": "Join super duper cool people!",
|
||||
@@ -865,7 +878,9 @@
|
||||
"name": "Mixer",
|
||||
"button": "Mix and match",
|
||||
"description": "Mix tank modules",
|
||||
"seo_description": "Mix and match hulls, turrets, and guns of tanks in World of Tanks Blitz"
|
||||
"seo_description": "Mix and match hulls, turrets, and guns of tanks in World of Tanks Blitz",
|
||||
"screenshot": "Screenshot",
|
||||
"randomize": "Randomize"
|
||||
},
|
||||
|
||||
"guess": {
|
||||
@@ -1446,17 +1461,11 @@
|
||||
"description": "Get started with BlitzKit",
|
||||
"seo_description": "Get started with BlitzKit"
|
||||
},
|
||||
"blitz_analysis": {
|
||||
"name": "BlitzAnalysis[]",
|
||||
"button": "Analyze now",
|
||||
"description": "Rich historic average stats",
|
||||
"seo_description": "Rich historic average stats in World of Tanks Blitz"
|
||||
},
|
||||
"blitz_insider": {
|
||||
"name": "Blitz Insider",
|
||||
"button": "Discover today",
|
||||
"description": "In-game session stats",
|
||||
"seo_description": "In-game session stats in World of Tanks Blitz"
|
||||
"api": {
|
||||
"name": "API",
|
||||
"button": "To the docs",
|
||||
"description": "BlitzKit hosted API",
|
||||
"seo_description": "BlitzKit hosted static API for World of Tanks Blitz"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -11,20 +11,21 @@
|
||||
"build:ids": "bun src/discoverIds.ts",
|
||||
"build:bot": "bun src/buildBot.ts",
|
||||
"build:ratingleaderboard": "bun src/buildRatingLeaderboard.ts",
|
||||
"build:proxyclient": "bun src/buildProxyClient.ts",
|
||||
"prunestrings": "bun src/pruneStrings.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzkit/core": "workspace:*",
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"@gltf-transform/core": "^4.0.10",
|
||||
"@gltf-transform/extensions": "^4.0.10",
|
||||
"@gltf-transform/functions": "^4.0.10",
|
||||
"csv-parse": "^5.5.6",
|
||||
"@gltf-transform/core": "^4.2.1",
|
||||
"@gltf-transform/extensions": "^4.2.1",
|
||||
"@gltf-transform/functions": "^4.2.1",
|
||||
"csv-parse": "^6.1.0",
|
||||
"decompress": "^4.2.1",
|
||||
"esbuild": "^0.19.12",
|
||||
"fast-xml-parser": "^4.4.1",
|
||||
"esbuild": "^0.25.10",
|
||||
"fast-xml-parser": "^5.2.5",
|
||||
"progress": "^2.0.3",
|
||||
"puppeteer": "^23.10.4"
|
||||
"puppeteer": "^24.22.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/decompress": "^4.2.7",
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { readFile, writeFile } from "fs/promises";
|
||||
|
||||
const IMPORT = "@protos/auto_legacy_proxy_client";
|
||||
const SOURCE =
|
||||
"../../submodules/blitzkit-closed/protos/auto_legacy_proxy_client.proto";
|
||||
const TARGET =
|
||||
"../../submodules/blitzkit-closed/src/unreal/methodPopulatedProxyClient.ts";
|
||||
|
||||
const requestPattern = /message (\w+)Request {/g;
|
||||
const source = await readFile(SOURCE).then((buffer) => buffer.toString());
|
||||
const requests = source.matchAll(requestPattern);
|
||||
|
||||
const imports: string[] = [];
|
||||
const methods: { name: string; method: string }[] = [];
|
||||
|
||||
for (const match of requests) {
|
||||
const name = match[1];
|
||||
// const method =
|
||||
// name.charAt(0).toLowerCase() + name.slice(1).replace(/Async$/, "");
|
||||
const method = name;
|
||||
|
||||
imports.push(`${name}Request`, `${name}Response`);
|
||||
methods.push({ name, method });
|
||||
}
|
||||
|
||||
let content = "";
|
||||
|
||||
content += "import {\n";
|
||||
content += imports.map((i) => ` ${i},`).join("\n");
|
||||
content += `\n} from "${IMPORT}";\n`;
|
||||
|
||||
content += 'import { BaseProxyClient } from "./baseProxyClient";\n\n';
|
||||
|
||||
content +=
|
||||
"export abstract class MethodPopulatedProxyClient extends BaseProxyClient {\n";
|
||||
content += methods
|
||||
.map(({ name, method }) => {
|
||||
return ` ${method}(data: ${name}Request) {
|
||||
return this.request("${name}Request", ${name}Request, data, ${name}Response);
|
||||
}\n`;
|
||||
})
|
||||
.join("");
|
||||
content += "}\n";
|
||||
|
||||
await writeFile(TARGET, content);
|
||||
@@ -1,47 +1,61 @@
|
||||
import { exec as execSync } from 'child_process';
|
||||
import { existsSync } from 'fs';
|
||||
import { readdir, rm, writeFile } from 'fs/promises';
|
||||
import { promisify } from 'util';
|
||||
import { exec as execSync } from "child_process";
|
||||
import { existsSync } from "fs";
|
||||
import { readdir, rm } from "fs/promises";
|
||||
import { promisify } from "util";
|
||||
|
||||
const ROOT = 'packages/core/src/protos';
|
||||
const MAX_COMMAND_LENGTH = 2 ** 11;
|
||||
|
||||
const roots = [
|
||||
// "packages/core/src/protos",
|
||||
"submodules/blitzkit-closed/protos",
|
||||
];
|
||||
|
||||
const exec = promisify(execSync);
|
||||
|
||||
let executableFileExtension: string;
|
||||
|
||||
if (existsSync('node_modules/.bin/protoc-gen-ts_proto.exe')) {
|
||||
executableFileExtension = '.exe';
|
||||
if (existsSync("node_modules/.bin/protoc-gen-ts_proto.exe")) {
|
||||
executableFileExtension = ".exe";
|
||||
} else {
|
||||
executableFileExtension = '';
|
||||
executableFileExtension = "";
|
||||
}
|
||||
|
||||
const filesRaw = await readdir(`${ROOT}`);
|
||||
await Promise.all(
|
||||
filesRaw.map(async (file) => {
|
||||
if (!file.endsWith('.proto')) {
|
||||
await rm(`${ROOT}/${file}`);
|
||||
for (const root of roots) {
|
||||
const filesRaw = await readdir(`${root}`);
|
||||
const files: string[] = [];
|
||||
|
||||
for (const file of filesRaw) {
|
||||
if (file.endsWith(".proto")) files.push(file);
|
||||
if (file.endsWith(".ts")) await rm(`${root}/${file}`);
|
||||
}
|
||||
|
||||
while (files.length > 0) {
|
||||
let command = [
|
||||
"protoc",
|
||||
`--plugin=./node_modules/.bin/protoc-gen-ts_proto${executableFileExtension}`,
|
||||
"--ts_proto_opt=esModuleInterop=true",
|
||||
"--ts_proto_opt=oneof=unions-value",
|
||||
// "--ts_proto_opt=removeEnumPrefix=true",
|
||||
"--ts_proto_opt=unrecognizedEnum=false",
|
||||
"--ts_proto_opt=snakeToCamel=false",
|
||||
`--ts_proto_out=${root}`,
|
||||
`-I=${root}`,
|
||||
].join(" ");
|
||||
|
||||
while (true) {
|
||||
if (files.length === 0) break;
|
||||
|
||||
const file = files.at(-1);
|
||||
const newLine = ` ${root}/${file}`;
|
||||
|
||||
if (command.length + newLine.length < MAX_COMMAND_LENGTH) {
|
||||
command += newLine;
|
||||
files.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
const files = filesRaw.filter((file) => file.endsWith('.proto'));
|
||||
const args = [
|
||||
`--plugin=./node_modules/.bin/protoc-gen-ts_proto${executableFileExtension}`,
|
||||
'--ts_proto_opt=esModuleInterop=true',
|
||||
'--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}`),
|
||||
];
|
||||
|
||||
await exec(`protoc ${args.join(' ')}`);
|
||||
await writeFile(
|
||||
`${ROOT}/index.ts`,
|
||||
'// @ts-nocheck\n' +
|
||||
files
|
||||
.map((file) => file.replace('.proto', ''))
|
||||
.map((file) => `export * from './${file}.ts';`)
|
||||
.join('\n'),
|
||||
);
|
||||
await exec(command);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,26 @@
|
||||
import {
|
||||
DEFAULT_LOCALE,
|
||||
SUPPORTED_LOCALES,
|
||||
TranslationTree,
|
||||
} from '@blitzkit/i18n';
|
||||
import { writeFile } from 'fs/promises';
|
||||
import { type TranslationTree } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { writeFile } from "fs/promises";
|
||||
|
||||
const ROOT = '@blitzkit/i18n/strings';
|
||||
const WORKING_ROOT = '../../packages/i18n/strings';
|
||||
const ROOT = "@blitzkit/i18n/strings";
|
||||
const WORKING_ROOT = "../../packages/i18n/strings";
|
||||
|
||||
const defaultStrings = require(`${ROOT}/${DEFAULT_LOCALE}.json`).default;
|
||||
const nonDefaultLocales = SUPPORTED_LOCALES.filter(
|
||||
(locale) => locale !== DEFAULT_LOCALE,
|
||||
const defaultStrings = require(`${ROOT}/${locales.default}.json`).default;
|
||||
const nonDefaultLocales = locales.supported.filter(
|
||||
({ locale }) => locale !== locales.default
|
||||
);
|
||||
|
||||
function prune(defaultStrings: TranslationTree, strings: TranslationTree) {
|
||||
for (const key in strings) {
|
||||
if (key in defaultStrings) {
|
||||
if (typeof defaultStrings[key] === typeof strings[key]) {
|
||||
if (typeof strings[key] === 'string') {
|
||||
if (typeof strings[key] === "string") {
|
||||
if (
|
||||
// are equivalent regardless of %s flavor
|
||||
(defaultStrings[key] as string).replaceAll(/%s\d/g, '%s') ===
|
||||
(strings[key] as string).replaceAll(/%s\d/g, '%s') ||
|
||||
(defaultStrings[key] as string).replaceAll(/%s\d/g, "%s") ===
|
||||
(strings[key] as string).replaceAll(/%s\d/g, "%s") ||
|
||||
// string is empty
|
||||
strings[key] === '' ||
|
||||
strings[key] === "" ||
|
||||
// string has old flavor of %s
|
||||
strings[key].match(/%s([^\d]|$)/g) !== null
|
||||
) {
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"dependencies": {
|
||||
"react": "^18.3.1"
|
||||
"react": "^19.1.1"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { produce } from "immer";
|
||||
import { merge } from "lodash-es";
|
||||
import { useEffect, useState } from "react";
|
||||
import { debounce, merge } from "lodash-es";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
export class Varuna<Type, Arguments = void> {
|
||||
private listeners = new Set<(state: Type) => void>();
|
||||
@@ -20,7 +20,6 @@ export class Varuna<Type, Arguments = void> {
|
||||
let data = initial;
|
||||
|
||||
if (this.persistence && typeof localStorage !== "undefined") {
|
||||
const instance = this;
|
||||
const dehydrated = localStorage.getItem(this.persistence);
|
||||
|
||||
if (dehydrated) {
|
||||
@@ -28,9 +27,7 @@ export class Varuna<Type, Arguments = void> {
|
||||
data = merge(data, rehydrated);
|
||||
}
|
||||
|
||||
window.addEventListener("beforeunload", () => {
|
||||
localStorage.setItem(this.persistence!, JSON.stringify(instance.state));
|
||||
});
|
||||
window.addEventListener("beforeunload", this.store.bind(this));
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
@@ -39,13 +36,16 @@ export class Varuna<Type, Arguments = void> {
|
||||
}
|
||||
|
||||
useInitialization(...args: Arguments[]) {
|
||||
if (this.initialized) return;
|
||||
const initializedThisMount = useRef(false);
|
||||
|
||||
if (initializedThisMount.current) return;
|
||||
|
||||
if (typeof this.creator !== "function") {
|
||||
throw new Error("Provider must be used with a function creator");
|
||||
}
|
||||
|
||||
this.initialize((this.creator as (...args: Arguments[]) => Type)(...args));
|
||||
initializedThisMount.current = true;
|
||||
}
|
||||
|
||||
private dispatch() {
|
||||
@@ -91,6 +91,7 @@ export class Varuna<Type, Arguments = void> {
|
||||
this.assertInitialized();
|
||||
this._state = state;
|
||||
this.dispatch();
|
||||
this.storeDeferred();
|
||||
}
|
||||
|
||||
get initial() {
|
||||
@@ -112,4 +113,10 @@ export class Varuna<Type, Arguments = void> {
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
||||
store() {
|
||||
localStorage.setItem(this.persistence!, JSON.stringify(this.state));
|
||||
}
|
||||
|
||||
storeDeferred = debounce(this.store.bind(this), 500);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# build output
|
||||
dist/
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
||||
# jetbrains setting folder
|
||||
.idea/
|
||||
.vercel/
|
||||
@@ -1,35 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import react from '@astrojs/react';
|
||||
import sitemap from '@astrojs/sitemap';
|
||||
import { SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
export default defineConfig({
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: [...SUPPORTED_LOCALES],
|
||||
routing: {
|
||||
prefixDefaultLocale: false,
|
||||
},
|
||||
},
|
||||
|
||||
devToolbar: { enabled: false },
|
||||
output: 'static',
|
||||
site: 'https://blitzkit.app',
|
||||
outDir: '../../dist/website',
|
||||
prefetch: true,
|
||||
|
||||
integrations: [react(), sitemap()],
|
||||
vite: {
|
||||
resolve: {
|
||||
alias: {
|
||||
'.prisma/client/index-browser':
|
||||
'../../node_modules/.prisma/client/index-browser.js',
|
||||
},
|
||||
},
|
||||
ssr: {
|
||||
noExternal: [/^d3.*$/, /^@nivo.*$/],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
import react from "@astrojs/react";
|
||||
import { wrapper } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import strings from "@blitzkit/i18n/strings/en.json";
|
||||
import { mauve, mauveDark } from "@radix-ui/colors";
|
||||
import AstroPWA from "@vite-pwa/astro";
|
||||
import favicons from "astro-favicons";
|
||||
import { defineConfig } from "astro/config";
|
||||
import packageJSON from "../../package.json";
|
||||
import { tools } from "./src/constants/tools";
|
||||
|
||||
export default defineConfig({
|
||||
devToolbar: { enabled: false },
|
||||
|
||||
vite: { server: { allowedHosts: [] } },
|
||||
output: "static",
|
||||
site: "https://blitzkit.app",
|
||||
outDir: "../../dist/website",
|
||||
prefetch: {
|
||||
defaultStrategy: "hover",
|
||||
prefetchAll: true,
|
||||
},
|
||||
|
||||
build: { concurrency: 4 },
|
||||
|
||||
integrations: [
|
||||
favicons({
|
||||
name: strings.common.name,
|
||||
short_name: strings.common.name,
|
||||
|
||||
background: mauveDark.mauve1,
|
||||
themes: [mauve.mauve1, mauveDark.mauve1],
|
||||
appleStatusBarStyle: "black-translucent",
|
||||
|
||||
version: packageJSON.version,
|
||||
|
||||
shortcuts: Object.values(tools)
|
||||
.filter((tool) => !tool.disabled && !tool.href)
|
||||
.map((tool) => {
|
||||
const stringId = (tool.strings ??
|
||||
tool.id) as keyof typeof strings.website.tools;
|
||||
|
||||
return {
|
||||
name: strings.website.tools[stringId].name,
|
||||
name_localized: wrapper(
|
||||
(strings) => strings.website.tools[stringId].name
|
||||
),
|
||||
description: strings.website.tools[stringId].description,
|
||||
description_localized: wrapper(
|
||||
(strings) => strings.website.tools[stringId].description
|
||||
),
|
||||
short_name: strings.website.tools[stringId].name,
|
||||
short_name_localized: wrapper(
|
||||
(strings) => strings.website.tools[stringId].name
|
||||
),
|
||||
url: `/${tool.id}`,
|
||||
icon: `public/assets/images/tools/${tool.id}.webp`,
|
||||
};
|
||||
}),
|
||||
|
||||
manifest: {
|
||||
description: strings.website.home.seo_description,
|
||||
description_localized: wrapper(
|
||||
(strings) => strings.website.home.seo_description
|
||||
),
|
||||
|
||||
dir: "ltr",
|
||||
categories: ["utilities", "games", "developer", "developer tools"],
|
||||
|
||||
id: "com.tresabhi.blitzkit",
|
||||
start_url: "/",
|
||||
launch_handler: { client_mode: "navigate-new" },
|
||||
display: "fullscreen",
|
||||
display_override: ["fullscreen", "standalone", "minimal-ui"],
|
||||
|
||||
lang: locales.default,
|
||||
orientation: "any",
|
||||
},
|
||||
|
||||
icons: {
|
||||
windows: true,
|
||||
android: true,
|
||||
appleIcon: true,
|
||||
appleStartup: true,
|
||||
favicons: true,
|
||||
yandex: true,
|
||||
},
|
||||
}),
|
||||
|
||||
AstroPWA({
|
||||
manifest: false,
|
||||
devOptions: { enabled: true },
|
||||
workbox: {
|
||||
globPatterns: ["**/*.{html,css,js,png,webp,svg,xml,json}"],
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ url }) =>
|
||||
url.href.startsWith(import.meta.env.PUBLIC_ASSET_BASE),
|
||||
handler: "NetworkFirst",
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
|
||||
react(),
|
||||
],
|
||||
});
|
||||
@@ -3,52 +3,35 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"lint": "astro check",
|
||||
"build": "astro check && astro build",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"lint": "astro check",
|
||||
"astro": "astro"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrolib/seo": "^1.0.0-beta.8",
|
||||
"@blitzkit/core": "workspace:*",
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"varuna": "workspace:*",
|
||||
"@fontsource/inter": "^5.2.5",
|
||||
"@nanostores/persistent": "^0.10.2",
|
||||
"@nanostores/react": "^0.7.3",
|
||||
"@nivo/bar": "^0.87.0",
|
||||
"@nivo/line": "^0.88.0",
|
||||
"@radix-ui/colors": "^3.0.0",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@radix-ui/themes": "^3.1.4",
|
||||
"@react-three/drei": "^9.115.0",
|
||||
"@react-three/fiber": "^8.17.10",
|
||||
"compare-versions": "^6.1.1",
|
||||
"echarts": "^5.5.1",
|
||||
"immer": "^10.1.1",
|
||||
"js-cookie": "^3.0.5",
|
||||
"markdown-to-jsx": "^7.5.0",
|
||||
"nanostores": "^0.11.3",
|
||||
"quicklime": "^1.2.0",
|
||||
"react": "^18.3.1",
|
||||
"react-device-detect": "^2.2.3",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-promise-suspense": "^0.3.4",
|
||||
"three": "^0.169.0",
|
||||
"urlon": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.9.4",
|
||||
"@astrojs/react": "^3.6.2",
|
||||
"@astrojs/sitemap": "^3.2.1",
|
||||
"@playform/compress": "^0.1.9",
|
||||
"@playform/inline": "^0.1.2",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/three": "^0.160.0",
|
||||
"astro": "^4.16.7",
|
||||
"astro-compressor": "^1.0.0"
|
||||
"@astrojs/react": "^4.4.0",
|
||||
"@astrolib/seo": "^1.0.0-beta.8",
|
||||
"@fontsource/inter": "^5.2.8",
|
||||
"@radix-ui/colors": "^3.0.0",
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
"@radix-ui/themes": "^3.2.1",
|
||||
"@react-three/drei": "^10.7.6",
|
||||
"@react-three/fiber": "^9.3.0",
|
||||
"@types/react": "^19.1.14",
|
||||
"@types/react-dom": "^19.1.9",
|
||||
"@vite-pwa/astro": "^1.1.0",
|
||||
"astro": "^5.14.1",
|
||||
"astro-favicons": "^3.1.5",
|
||||
"compare-versions": "^6.1.1",
|
||||
"fuzzysort": "^3.1.0",
|
||||
"immer": "^10.1.3",
|
||||
"markdown-to-jsx": "^7.7.13",
|
||||
"pwa-install-handler": "^2.6.3",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react-promise-suspense": "^0.3.4",
|
||||
"typescript": "^5.9.2",
|
||||
"urlon": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 170 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 367 KiB |
|
Before Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 692 B |
@@ -0,0 +1,46 @@
|
||||
<svg width="426" height="426" viewBox="0 0 426 426" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M416.628 244.997L235.625 372.974C223.13 381.809 202.87 381.809 190.375 372.974L9.37173 244.997C3.1239 240.58 -3.95076e-06 234.79 0 229V196.6H426V229C426 234.79 422.876 240.58 416.628 244.997Z" fill="#0D2847"/>
|
||||
<path d="M416.628 180.603L235.625 52.6262C223.13 43.7913 202.87 43.7913 190.375 52.6262L9.37172 180.603C-3.12391 189.438 -3.12391 203.762 9.37173 212.597L190.375 340.574C202.87 349.409 223.13 349.409 235.625 340.574L416.628 212.597C429.124 203.762 429.124 189.438 416.628 180.603Z" fill="#D9D9D9"/>
|
||||
<path d="M416.628 180.603L235.625 52.6262C223.13 43.7913 202.87 43.7913 190.375 52.6262L9.37172 180.603C-3.12391 189.438 -3.12391 203.762 9.37173 212.597L190.375 340.574C202.87 349.409 223.13 349.409 235.625 340.574L416.628 212.597C429.124 203.762 429.124 189.438 416.628 180.603Z" fill="url(#paint0_linear_764_240)"/>
|
||||
<path d="M416.628 180.603L235.625 52.6262C223.13 43.7913 202.87 43.7913 190.375 52.6262L9.37172 180.603C-3.12391 189.438 -3.12391 203.762 9.37173 212.597L190.375 340.574C202.87 349.409 223.13 349.409 235.625 340.574L416.628 212.597C429.124 203.762 429.124 189.438 416.628 180.603Z" fill="url(#paint1_linear_764_240)"/>
|
||||
<g filter="url(#filter0_d_764_240)">
|
||||
<path d="M197.056 150.108L201.368 153.051L290.596 213.945L306.6 202.599L310.832 199.599L289.153 184.23L288.86 177.31L335.236 182.298L351.706 170.622L359.102 165.378L288.049 158.111L286.355 118L263.968 133.871L265.867 167.722L217.292 135.762L197.056 150.108Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M192.905 289L74.2242 204.714L70 201.714L116.393 168.767C129.906 159.17 143.124 153.539 156.048 151.875C168.971 150.211 180.919 153.275 191.893 161.069C198.702 165.905 202.718 171.006 203.941 176.372C205.165 181.658 204.302 186.506 201.354 190.918L201.692 191.158C208.978 188.301 216.935 187.286 225.563 188.113C234.247 188.9 242.613 192.151 250.66 197.866C261.803 205.779 266.398 214.825 264.446 225.004C262.551 235.142 254.96 244.929 241.672 254.366L192.905 289ZM221.999 242.08L200.456 257.38L163.905 231.422L185.448 216.123C192.007 211.465 198.473 209.23 204.846 209.42C211.22 209.529 217.193 211.562 222.764 215.519C228.392 219.516 231.31 223.797 231.521 228.364C231.732 232.85 228.558 237.422 221.999 242.08ZM165.937 205.64L146.77 219.252L114.693 196.472L133.861 182.859C140.363 178.241 146.435 175.887 152.076 175.798C157.717 175.708 163.07 177.462 168.135 181.059C173.256 184.696 175.809 188.557 175.796 192.643C175.726 196.69 172.44 201.022 165.937 205.64Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path d="M197.056 156.108L290.596 219.945L310.832 205.599L306.6 202.599L289.153 190.23L288.86 183.31L335.236 188.298L359.102 171.378L351.706 170.622L288.049 164.111L286.355 124L263.968 139.871L265.867 173.722L217.292 141.762L201.368 153.051L197.056 156.108Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M192.905 295L70 207.714L74.2242 204.714L116.393 174.767C129.906 165.17 143.124 159.539 156.048 157.875C168.971 156.211 180.919 159.275 191.893 167.069C198.702 171.905 202.718 177.006 203.941 182.372C205.165 187.658 204.302 192.506 201.354 196.918L201.692 197.158C208.978 194.301 216.935 193.286 225.563 194.113C234.247 194.9 242.613 198.151 250.66 203.866C261.803 211.779 266.398 220.825 264.446 231.004C262.551 241.142 254.96 250.929 241.672 260.366L192.905 295ZM221.999 248.08L200.456 263.38L163.905 237.422L185.448 222.123C192.007 217.465 198.473 215.23 204.846 215.42C211.22 215.529 217.193 217.562 222.764 221.519C228.392 225.516 231.31 229.797 231.521 234.364C231.732 238.85 228.558 243.422 221.999 248.08ZM165.937 211.64L146.77 225.252L114.693 202.472L133.861 188.859C140.363 184.241 146.435 181.887 152.076 181.798C157.717 181.708 163.07 183.462 168.135 187.059C173.256 190.696 175.809 194.557 175.796 198.643C175.726 202.69 172.44 207.022 165.937 211.64Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path d="M310.832 199.599L306.6 202.599L310.832 205.599V199.599Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path d="M359.102 165.378L351.706 170.622L359.102 171.378V165.378Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path d="M201.368 153.051L197.056 150.108V156.108L201.368 153.051Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
<path d="M74.2242 204.714L70 201.714V207.714L74.2242 204.714Z" fill="#111927" fill-opacity="0.5" shape-rendering="crispEdges"/>
|
||||
</g>
|
||||
<path d="M197.056 150.108L290.596 213.945L310.832 199.599L289.153 184.23L288.86 177.31L335.236 182.298L359.102 165.378L288.049 158.111L286.355 118L263.968 133.871L265.867 167.722L217.292 135.762L197.056 150.108Z" fill="url(#paint2_linear_764_240)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M192.905 289L70 201.714L116.393 168.767C129.906 159.17 143.124 153.539 156.048 151.875C168.971 150.211 180.919 153.275 191.893 161.069C198.702 165.905 202.718 171.006 203.941 176.372C205.165 181.658 204.302 186.506 201.354 190.918L201.692 191.158C208.978 188.301 216.935 187.286 225.563 188.113C234.247 188.9 242.613 192.151 250.66 197.866C261.803 205.779 266.398 214.825 264.446 225.004C262.551 235.142 254.96 244.929 241.672 254.366L192.905 289ZM221.999 242.08L200.456 257.38L163.905 231.422L185.448 216.123C192.007 211.465 198.473 209.23 204.846 209.42C211.22 209.529 217.193 211.562 222.764 215.519C228.392 219.516 231.31 223.797 231.521 228.364C231.732 232.85 228.558 237.422 221.999 242.08ZM165.937 205.64L146.77 219.252L114.693 196.472L133.861 182.859C140.363 178.241 146.435 175.887 152.076 175.798C157.717 175.708 163.07 177.462 168.135 181.059C173.256 184.696 175.809 188.557 175.796 192.643C175.726 196.69 172.44 201.022 165.937 205.64Z" fill="url(#paint3_linear_764_240)"/>
|
||||
<defs>
|
||||
<filter id="filter0_d_764_240" x="66" y="116" width="297.103" height="185" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="2"/>
|
||||
<feGaussianBlur stdDeviation="2"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_764_240"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_764_240" result="shape"/>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_764_240" x1="213" y1="46" x2="213" y2="347.2" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#10243E"/>
|
||||
<stop offset="1" stop-color="#0F1B2D"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_764_240" x1="127.008" y1="96.51" x2="241.48" y2="334.974" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#262A65"/>
|
||||
<stop offset="1" stop-color="#104D87"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_764_240" x1="215" y1="98.5" x2="299.5" y2="210.5" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.379808" stop-color="#C2E6FF"/>
|
||||
<stop offset="0.706731" stop-color="#70B8FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_764_240" x1="215" y1="98.5" x2="299.5" y2="210.5" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.379808" stop-color="#C2E6FF"/>
|
||||
<stop offset="0.706731" stop-color="#70B8FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.3 KiB |
@@ -1,7 +1,8 @@
|
||||
import type { GroupProps } from '@react-three/fiber';
|
||||
import { forwardRef } from 'react';
|
||||
import { Group } from 'three';
|
||||
import { forwardRef, type ComponentProps } from "react";
|
||||
import { Group } from "three";
|
||||
|
||||
export const ModelTankWrapper = forwardRef<Group, GroupProps>((props, ref) => {
|
||||
return <group rotation={[-Math.PI / 2, 0, 0]} ref={ref} {...props} />;
|
||||
});
|
||||
export const ModelTankWrapper = forwardRef<Group, ComponentProps<"group">>(
|
||||
(props, ref) => {
|
||||
return <group rotation={[-Math.PI / 2, 0, 0]} ref={ref} {...props} />;
|
||||
}
|
||||
);
|
||||
@@ -1,19 +1,19 @@
|
||||
import { memo, useRef } from 'react';
|
||||
import { Group } from 'three';
|
||||
import { correctZYTuple } from '../../../core/blitz/correctZYTuple';
|
||||
import { nameToArmorId } from '../../../core/blitzkit/nameToArmorId';
|
||||
import { resolveArmor } from '../../../core/blitzkit/resolveThickness';
|
||||
import { useArmor } from '../../../hooks/useArmor';
|
||||
import { useTankModelDefinition } from '../../../hooks/useTankModelDefinition';
|
||||
import { useTankTransform } from '../../../hooks/useTankTransform';
|
||||
import { Duel } from '../../../stores/duel';
|
||||
import { ModelTankWrapper } from './ModelTankWrapper';
|
||||
import { PrimaryArmorSceneComponent } from './PrimaryArmorSceneComponent';
|
||||
import { memo, useRef } from "react";
|
||||
import { Group } from "three";
|
||||
import { correctZYTuple } from "../../../core/blitz/correctZYTuple";
|
||||
import { nameToArmorId } from "../../../core/blitzkit/nameToArmorId";
|
||||
import { resolveArmor } from "../../../core/blitzkit/resolveThickness";
|
||||
import { useArmor } from "../../../hooks/useArmor";
|
||||
import { useTankModelDefinition } from "../../../hooks/useTankModelDefinition";
|
||||
import { useTankTransform } from "../../../hooks/useTankTransform";
|
||||
import { Duel } from "../../../stores/duel";
|
||||
import { ModelTankWrapper } from "./ModelTankWrapper";
|
||||
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
|
||||
|
||||
export const PrimaryArmorScene = memo(() => {
|
||||
const wrapper = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null);
|
||||
const gunContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null!);
|
||||
const gunContainer = useRef<Group>(null!);
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
const track = Duel.use((state) => state.protagonist.track);
|
||||
const turret = Duel.use((state) => state.protagonist.turret);
|
||||
@@ -28,7 +28,7 @@ export const PrimaryArmorScene = memo(() => {
|
||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin);
|
||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin);
|
||||
const isDynamicArmorActive = Duel.use((state) =>
|
||||
state.protagonist.consumables.includes(73),
|
||||
state.protagonist.consumables.includes(73)
|
||||
);
|
||||
|
||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||
@@ -37,20 +37,20 @@ export const PrimaryArmorScene = memo(() => {
|
||||
<ModelTankWrapper ref={wrapper}>
|
||||
<group position={hullOrigin}>
|
||||
{armorNodes.map((node) => {
|
||||
const isHull = node.name.startsWith('hull_');
|
||||
const isHull = node.name.startsWith("hull_");
|
||||
const isVisible = isHull;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
tankModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
spaced ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_01')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_00'))
|
||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
||||
)
|
||||
return null;
|
||||
|
||||
@@ -67,21 +67,21 @@ export const PrimaryArmorScene = memo(() => {
|
||||
<group ref={turretContainer}>
|
||||
{armorNodes.map((node) => {
|
||||
const isCurrentTurret = node.name.startsWith(
|
||||
`turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`,
|
||||
`turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`
|
||||
);
|
||||
const isVisible = isCurrentTurret;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
turretModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
spaced ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_01')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_00'))
|
||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
||||
)
|
||||
return null;
|
||||
|
||||
@@ -101,21 +101,21 @@ export const PrimaryArmorScene = memo(() => {
|
||||
<group ref={gunContainer}>
|
||||
{armorNodes.map((node) => {
|
||||
const isCurrentGun = node.name.startsWith(
|
||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`,
|
||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`
|
||||
);
|
||||
const isVisible = isCurrentGun;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
gunModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
spaced ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_01')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_00'))
|
||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
||||
)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { memo, useRef } from 'react';
|
||||
import { Group, Plane, Scene, Vector3 } from 'three';
|
||||
import { correctZYTuple } from '../../../core/blitz/correctZYTuple';
|
||||
import { nameToArmorId } from '../../../core/blitzkit/nameToArmorId';
|
||||
import { resolveArmor } from '../../../core/blitzkit/resolveThickness';
|
||||
import { useArmor } from '../../../hooks/useArmor';
|
||||
import { useModel } from '../../../hooks/useModel';
|
||||
import { useTankModelDefinition } from '../../../hooks/useTankModelDefinition';
|
||||
import { useTankTransform } from '../../../hooks/useTankTransform';
|
||||
import { Duel } from '../../../stores/duel';
|
||||
import { ModelTankWrapper } from './ModelTankWrapper';
|
||||
import { SpacedArmorSceneComponent } from './SpacedArmorSceneComponent';
|
||||
import { memo, useRef } from "react";
|
||||
import { Group, Plane, Scene, Vector3 } from "three";
|
||||
import { correctZYTuple } from "../../../core/blitz/correctZYTuple";
|
||||
import { nameToArmorId } from "../../../core/blitzkit/nameToArmorId";
|
||||
import { resolveArmor } from "../../../core/blitzkit/resolveThickness";
|
||||
import { useArmor } from "../../../hooks/useArmor";
|
||||
import { useModel } from "../../../hooks/useModel";
|
||||
import { useTankModelDefinition } from "../../../hooks/useTankModelDefinition";
|
||||
import { useTankTransform } from "../../../hooks/useTankTransform";
|
||||
import { Duel } from "../../../stores/duel";
|
||||
import { ModelTankWrapper } from "./ModelTankWrapper";
|
||||
import { SpacedArmorSceneComponent } from "./SpacedArmorSceneComponent";
|
||||
|
||||
export enum ArmorType {
|
||||
Primary,
|
||||
@@ -23,8 +23,8 @@ interface SpacedArmorSceneProps {
|
||||
|
||||
export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
const wrapper = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null);
|
||||
const gunContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null!);
|
||||
const gunContainer = useRef<Group>(null!);
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
const track = Duel.use((state) => state.protagonist.track);
|
||||
const turret = Duel.use((state) => state.protagonist.turret);
|
||||
@@ -45,7 +45,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
? undefined
|
||||
: gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
|
||||
const isDynamicArmorActive = Duel.use((state) =>
|
||||
state.protagonist.consumables.includes(73),
|
||||
state.protagonist.consumables.includes(73)
|
||||
);
|
||||
|
||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||
@@ -54,19 +54,19 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
<ModelTankWrapper ref={wrapper}>
|
||||
<group position={hullOrigin}>
|
||||
{armorNodes.map((node) => {
|
||||
const isHull = node.name.startsWith('hull_');
|
||||
const isHull = node.name.startsWith("hull_");
|
||||
const isVisible = isHull;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
tankModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_00')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_01'))
|
||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
||||
)
|
||||
return null;
|
||||
|
||||
@@ -83,8 +83,8 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
</group>
|
||||
|
||||
{modelNodes.map((node) => {
|
||||
const isWheel = node.name.startsWith('chassis_wheel_');
|
||||
const isTrack = node.name.startsWith('chassis_track_');
|
||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
||||
const isTrack = node.name.startsWith("chassis_track_");
|
||||
const isVisible = isWheel || isTrack;
|
||||
|
||||
if (!isVisible) return null;
|
||||
@@ -104,20 +104,20 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
<group ref={turretContainer}>
|
||||
{armorNodes.map((node) => {
|
||||
const isCurrentTurret = node.name.startsWith(
|
||||
`turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`,
|
||||
`turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`
|
||||
);
|
||||
const isVisible = isCurrentTurret;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
turretModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_00')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_01'))
|
||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
||||
)
|
||||
return null;
|
||||
|
||||
@@ -139,20 +139,20 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
<group ref={gunContainer}>
|
||||
{armorNodes.map((node) => {
|
||||
const isCurrentGun = node.name.startsWith(
|
||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`,
|
||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`
|
||||
);
|
||||
const isVisible = isCurrentGun;
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
gunModelDefinition.armor,
|
||||
armorId,
|
||||
armorId
|
||||
);
|
||||
|
||||
if (
|
||||
!isVisible ||
|
||||
thickness === undefined ||
|
||||
(isDynamicArmorActive && node.name.includes('state_00')) ||
|
||||
(!isDynamicArmorActive && node.name.includes('state_01'))
|
||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
||||
)
|
||||
return null;
|
||||
|
||||
@@ -173,7 +173,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||
{modelNodes.map((node) => {
|
||||
const gunString = `gun_${gunModelDefinition.model_id
|
||||
.toString()
|
||||
.padStart(2, '0')}`;
|
||||
.padStart(2, "0")}`;
|
||||
const isCurrentGun = gunModelDefinition.mask
|
||||
? node.name.startsWith(gunString)
|
||||
: node.name === gunString;
|
||||
|
||||
@@ -28,8 +28,8 @@ export interface ThicknessRange {
|
||||
|
||||
export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
||||
const wrapper = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null);
|
||||
const gunContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null!);
|
||||
const gunContainer = useRef<Group>(null!);
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
const track = Duel.use((state) => state.protagonist.track);
|
||||
const turret = Duel.use((state) => state.protagonist.turret);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { I_HAT, J_HAT } from "@blitzkit/core";
|
||||
import { type MeshProps, useThree } from "@react-three/fiber";
|
||||
import { useThree } from "@react-three/fiber";
|
||||
import { clamp } from "lodash-es";
|
||||
import type { QuicklimeEvent } from "quicklime";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useEffect, useMemo, type ComponentProps } from "react";
|
||||
import {
|
||||
Box3,
|
||||
Color,
|
||||
@@ -19,8 +19,8 @@ import {
|
||||
import { unrotateDavaVector } from "../../../core/blitz/unrotateDavaVector";
|
||||
import { jsxTree } from "../../../core/blitzkit/jsxTree";
|
||||
import {
|
||||
type ModelTransformEventData,
|
||||
modelTransformEvent,
|
||||
type ModelTransformEventData,
|
||||
} from "../../../core/blitzkit/modelTransform";
|
||||
import { discardClippingPlane } from "../../../core/three/discardClippingPlane";
|
||||
import { Tankopedia } from "../../../stores/tankopedia";
|
||||
@@ -36,7 +36,7 @@ type StaticArmorSceneComponentProps = {
|
||||
thickness: number;
|
||||
thicknessRange: ThicknessRange;
|
||||
node: Object3D;
|
||||
onPointerDown?: MeshProps["onPointerDown"];
|
||||
onPointerDown?: ComponentProps<"mesh">["onPointerDown"];
|
||||
} & (
|
||||
| {
|
||||
type: Exclude<ArmorType, ArmorType.External>;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Theme, type ThemeProps } from '@radix-ui/themes';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Theme, type ThemeProps } from "@radix-ui/themes";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface BlitzKitThemeProps extends ThemeProps {
|
||||
children: ReactNode;
|
||||
@@ -13,13 +13,13 @@ export function BlitzKitTheme({
|
||||
}: BlitzKitThemeProps) {
|
||||
return (
|
||||
<Theme
|
||||
style={{ minHeight: 'unset', display: 'contents', ...style }}
|
||||
style={{ minHeight: "unset", display: "contents", ...style }}
|
||||
className={`blitzkit-theme ${className}`}
|
||||
grayColor="mauve"
|
||||
appearance="dark"
|
||||
panelBackground="solid"
|
||||
radius="full"
|
||||
accentColor="amber"
|
||||
accentColor="indigo"
|
||||
suppressHydrationWarning
|
||||
suppressContentEditableWarning
|
||||
{...props}
|
||||
|
||||
@@ -16,7 +16,7 @@ interface TankControlProps {
|
||||
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||
|
||||
export function TankControl({ index, slug }: TankControlProps) {
|
||||
const { locale } = useLocale();
|
||||
const { locale, strings } = useLocale();
|
||||
const [switchTankDialogOpen, setSwitchTankDialogOpen] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -44,7 +44,9 @@ export function TankControl({ index, slug }: TankControlProps) {
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Content>
|
||||
<Dialog.Title align="center">Switch tanks</Dialog.Title>
|
||||
<Dialog.Title align="center">
|
||||
{strings.website.common.tank_search.swap_dialog_title}
|
||||
</Dialog.Title>
|
||||
|
||||
<Flex gap="4" direction="column">
|
||||
<Flex
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
import { localizedHTML as favicons } from "astro-favicons/middleware";
|
||||
|
||||
const { locale } = Astro.params;
|
||||
---
|
||||
|
||||
<Fragment set:html={favicons(locale)} />
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
import { assertSecret, fetchGameDefinitions } from '@blitzkit/core';
|
||||
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
||||
import { Box, Code, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
||||
import packageJson from '../../../../package.json';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { LinkI18n } from './LinkI18n';
|
||||
import { LocaleSwitcherThemeWrapper } from './LocaleSwitcher';
|
||||
import { assertSecret, fetchGameDefinitions } from "@blitzkit/core";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { Box, Code, Flex, Heading, Link, Text } from "@radix-ui/themes";
|
||||
import packageJson from "../../../../package.json";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
import { LinkI18n } from "./LinkI18n";
|
||||
import { LocaleSwitcherThemeWrapper } from "./LocaleSwitcher";
|
||||
|
||||
const gameDefinitions = await fetchGameDefinitions();
|
||||
const PUBLIC_ASSET_BRANCH = assertSecret(import.meta.env.PUBLIC_BRANCH);
|
||||
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||
const locale = Astro.params.locale ?? locales.default;
|
||||
const strings = getStrings(locale);
|
||||
---
|
||||
|
||||
@@ -28,13 +28,13 @@ const strings = getStrings(locale);
|
||||
flexGrow="1"
|
||||
gap="5"
|
||||
position="relative"
|
||||
direction={{ initial: 'column', sm: 'row' }}
|
||||
direction={{ initial: "column", sm: "row" }}
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
align={{
|
||||
initial: 'center',
|
||||
sm: 'start',
|
||||
initial: "center",
|
||||
sm: "start",
|
||||
}}
|
||||
>
|
||||
<Heading>BlitzKit</Heading>
|
||||
@@ -51,32 +51,32 @@ const strings = getStrings(locale);
|
||||
<Flex
|
||||
gap="6"
|
||||
width={{
|
||||
initial: '100%',
|
||||
sm: 'auto',
|
||||
initial: "100%",
|
||||
sm: "auto",
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
gap="1"
|
||||
align={{
|
||||
initial: 'end',
|
||||
sm: 'start',
|
||||
initial: "end",
|
||||
sm: "start",
|
||||
}}
|
||||
flexGrow={{
|
||||
initial: '1',
|
||||
sm: '0',
|
||||
initial: "1",
|
||||
sm: "0",
|
||||
}}
|
||||
flexBasis={{
|
||||
initial: '0',
|
||||
sm: 'auto',
|
||||
initial: "0",
|
||||
sm: "auto",
|
||||
}}
|
||||
>
|
||||
<Heading size="3">{strings.website.footer.about.title}</Heading>
|
||||
<Flex
|
||||
direction="column"
|
||||
align={{
|
||||
initial: 'end',
|
||||
sm: 'start',
|
||||
initial: "end",
|
||||
sm: "start",
|
||||
}}
|
||||
>
|
||||
<LinkI18n {locale} href="/docs/about/credits" color="gray">
|
||||
@@ -106,12 +106,12 @@ const strings = getStrings(locale);
|
||||
direction="column"
|
||||
gap="1"
|
||||
flexGrow={{
|
||||
initial: '1',
|
||||
sm: '0',
|
||||
initial: "1",
|
||||
sm: "0",
|
||||
}}
|
||||
flexBasis={{
|
||||
initial: '0',
|
||||
sm: 'auto',
|
||||
initial: "0",
|
||||
sm: "auto",
|
||||
}}
|
||||
>
|
||||
<Heading size="3">{strings.website.footer.legal.title}</Heading>
|
||||
@@ -127,11 +127,11 @@ const strings = getStrings(locale);
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
<Flex gap="5" display={{ initial: 'flex', sm: 'none' }} width="100%">
|
||||
<Flex gap="5" display={{ initial: "flex", sm: "none" }} width="100%">
|
||||
<Flex direction="column" gap="1" flexGrow="1" flexBasis="0" align="end">
|
||||
<Text size="2" color="gray">BlitzKit</Text>
|
||||
{
|
||||
PUBLIC_ASSET_BRANCH !== 'preview' && (
|
||||
PUBLIC_ASSET_BRANCH !== "preview" && (
|
||||
<Text size="2" color="gray">
|
||||
WoTB
|
||||
</Text>
|
||||
@@ -145,7 +145,7 @@ const strings = getStrings(locale);
|
||||
{packageJson.version}
|
||||
</Code>
|
||||
{
|
||||
PUBLIC_ASSET_BRANCH !== 'preview' && (
|
||||
PUBLIC_ASSET_BRANCH !== "preview" && (
|
||||
<Code size="2" color="gray">
|
||||
{gameDefinitions.version}
|
||||
</Code>
|
||||
@@ -157,14 +157,14 @@ const strings = getStrings(locale);
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
<Flex gap="2" align="center" display={{ initial: 'none', sm: 'flex' }}>
|
||||
<Flex gap="2" align="center" display={{ initial: "none", sm: "flex" }}>
|
||||
<Text size="2" color="gray">BlitzKit</Text>
|
||||
<Code size="2" color="gray">
|
||||
{packageJson.version}
|
||||
</Code>
|
||||
|
||||
{
|
||||
PUBLIC_ASSET_BRANCH !== 'preview' && (
|
||||
PUBLIC_ASSET_BRANCH !== "preview" && (
|
||||
<>
|
||||
<Text size="2" color="gray">
|
||||
WoTB
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { asset, Avatar } from '@blitzkit/core';
|
||||
import { Cross1Icon, DownloadIcon } from '@radix-ui/react-icons';
|
||||
import { asset, Avatar } from "@blitzkit/core";
|
||||
import { Cross1Icon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Dialog,
|
||||
Flex,
|
||||
@@ -7,11 +7,11 @@ import {
|
||||
Link,
|
||||
Skeleton,
|
||||
Text,
|
||||
} from '@radix-ui/themes';
|
||||
import { useRef } from 'react';
|
||||
import { useIntersection } from '../../hooks/useIntersection';
|
||||
import { useLocale } from '../../hooks/useLocale';
|
||||
import type { MaybeSkeletonComponentProps } from '../../types/maybeSkeletonComponentProps';
|
||||
} from "@radix-ui/themes";
|
||||
import { useRef } from "react";
|
||||
import { useIntersection } from "../../hooks/useIntersection";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||
|
||||
type GalleryCardProps = MaybeSkeletonComponentProps<{
|
||||
avatar: Avatar;
|
||||
@@ -19,9 +19,9 @@ type GalleryCardProps = MaybeSkeletonComponentProps<{
|
||||
|
||||
export function GalleryCard(props: GalleryCardProps) {
|
||||
const src = asset(
|
||||
`gallery/avatars/${!props.skeleton && `${props.avatar.id}${props.avatar.extension}`}`,
|
||||
`gallery/avatars/${!props.skeleton && `${props.avatar.id}${props.avatar.extension}`}`
|
||||
);
|
||||
const card = useRef<HTMLDivElement>(null);
|
||||
const card = useRef<HTMLDivElement>(null!);
|
||||
const { unwrap } = useLocale();
|
||||
|
||||
useIntersection(() => props.skeleton && props.onIntersection?.(), card, {
|
||||
@@ -35,7 +35,7 @@ export function GalleryCard(props: GalleryCardProps) {
|
||||
width="6rem"
|
||||
gap="1"
|
||||
ref={card}
|
||||
style={{ cursor: 'pointer' }}
|
||||
style={{ cursor: "pointer" }}
|
||||
>
|
||||
{props.skeleton && (
|
||||
<>
|
||||
@@ -48,16 +48,16 @@ export function GalleryCard(props: GalleryCardProps) {
|
||||
<>
|
||||
<img
|
||||
style={{
|
||||
width: '4rem',
|
||||
height: '4.57rem',
|
||||
width: "4rem",
|
||||
height: "4.57rem",
|
||||
// aspect ratio 7 / 8
|
||||
objectFit: 'cover',
|
||||
objectFit: "cover",
|
||||
}}
|
||||
src={src}
|
||||
alt={unwrap(props.avatar.name)}
|
||||
/>
|
||||
|
||||
<Text size="1" align="center" style={{ maxWidth: '100%' }}>
|
||||
<Text size="1" align="center" style={{ maxWidth: "100%" }}>
|
||||
{unwrap(props.avatar.name)}
|
||||
</Text>
|
||||
</>
|
||||
@@ -94,7 +94,7 @@ export function GalleryCard(props: GalleryCardProps) {
|
||||
</Flex>
|
||||
|
||||
<Flex justify="center" mt="4">
|
||||
<Dialog.Title align="center" style={{ maxWidth: '10rem' }}>
|
||||
<Dialog.Title align="center" style={{ maxWidth: "10rem" }}>
|
||||
{unwrap(props.avatar.name)}
|
||||
</Dialog.Title>
|
||||
</Flex>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { SpotLightProps } from '@react-three/fiber';
|
||||
import { memo } from 'react';
|
||||
import { memo, type ComponentProps } from "react";
|
||||
|
||||
interface Props extends SpotLightProps {
|
||||
interface Props extends ComponentProps<"spotLight"> {
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
||||
import { GlobeIcon } from '@radix-ui/react-icons';
|
||||
import { Flex, Text } from '@radix-ui/themes';
|
||||
import type { LocaleAcceptorProps } from '../../hooks/useLocale';
|
||||
import { BlitzKitTheme } from '../BlitzKitTheme';
|
||||
import { LocaleSwitcher } from '../LocaleSwitcher';
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { GlobeIcon } from "@radix-ui/react-icons";
|
||||
import { Flex, Text } from "@radix-ui/themes";
|
||||
import type { LocaleAcceptorProps } from "../../hooks/useLocale";
|
||||
import { BlitzKitTheme } from "../BlitzKitTheme";
|
||||
import { LocaleSwitcher } from "../LocaleSwitcher";
|
||||
|
||||
export function HomeLocaleSwitcher({
|
||||
locale = DEFAULT_LOCALE,
|
||||
locale = locales.default,
|
||||
}: LocaleAcceptorProps) {
|
||||
return (
|
||||
<BlitzKitTheme>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
||||
import { Link, type LinkProps } from '@radix-ui/themes';
|
||||
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { Link, type LinkProps } from "@radix-ui/themes";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
|
||||
type LinkI18nProps = LinkProps & LocaleAcceptorProps;
|
||||
|
||||
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
|
||||
const prefix =
|
||||
locale === undefined || locale === DEFAULT_LOCALE ? '' : `/${locale}`;
|
||||
locale === undefined || locale === locales.default ? "" : `/${locale}`;
|
||||
|
||||
return (
|
||||
<Link href={href?.startsWith('/') ? `${prefix}${href}` : href} {...props} />
|
||||
<Link href={href?.startsWith("/") ? `${prefix}${href}` : href} {...props} />
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<script>
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { getBestLocale } from "../core/i18n/getBestLocale";
|
||||
|
||||
const isAPI = window.location.pathname.startsWith("/api");
|
||||
const isI18nPath = locales.supported.some(({ locale }) =>
|
||||
window.location.pathname.startsWith(`/${locale}`)
|
||||
);
|
||||
const bestLocale = getBestLocale();
|
||||
const currentPathLocale = locales.supported.find(({ locale }) =>
|
||||
window.location.pathname.startsWith(`/${locale}`)
|
||||
);
|
||||
|
||||
if (
|
||||
!isAPI && // not an api, duh!
|
||||
localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler
|
||||
bestLocale !== currentPathLocale // we need to redirect
|
||||
) {
|
||||
window.location.pathname = isI18nPath
|
||||
? window.location.pathname.replace(
|
||||
`/${currentPathLocale}`,
|
||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
||||
)
|
||||
: `/${bestLocale}${window.location.pathname}`;
|
||||
}
|
||||
</script>
|
||||
@@ -1,17 +1,16 @@
|
||||
import {} from '@blitzkit/core';
|
||||
import {
|
||||
DEFAULT_LOCALE,
|
||||
STRINGS,
|
||||
SUPPORTED_LOCALES,
|
||||
SUPPORTED_LOCALE_FLAGS,
|
||||
} from '@blitzkit/i18n';
|
||||
import { Select } from '@radix-ui/themes';
|
||||
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
||||
import { BlitzKitTheme } from './BlitzKitTheme';
|
||||
type BlitzKitStrings,
|
||||
} from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { Select } from "@radix-ui/themes";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
import { BlitzKitTheme } from "./BlitzKitTheme";
|
||||
|
||||
export function LocaleSwitcherThemeWrapper({ locale }: LocaleAcceptorProps) {
|
||||
return (
|
||||
<BlitzKitTheme style={{ background: 'transparent' }}>
|
||||
<BlitzKitTheme style={{ background: "transparent" }}>
|
||||
<LocaleSwitcher locale={locale} />
|
||||
</BlitzKitTheme>
|
||||
);
|
||||
@@ -22,29 +21,33 @@ export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
|
||||
<Select.Root
|
||||
defaultValue={locale}
|
||||
onValueChange={(locale) => {
|
||||
localStorage.setItem('preferred-locale', locale);
|
||||
localStorage.setItem("preferred-locale", locale);
|
||||
|
||||
let rawPath = window.location.pathname;
|
||||
|
||||
for (const supportedLocale of SUPPORTED_LOCALES) {
|
||||
if (window.location.pathname.startsWith(`/${supportedLocale}`)) {
|
||||
rawPath = rawPath.replace(`/${supportedLocale}`, '');
|
||||
for (const supported of locales.supported) {
|
||||
if (window.location.pathname.startsWith(`/${supported.locale}`)) {
|
||||
rawPath = rawPath.replace(`/${supported.locale}`, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.location.pathname = `${
|
||||
locale === DEFAULT_LOCALE ? '' : `/${locale}`
|
||||
locale === locales.default ? "" : `/${locale}`
|
||||
}${rawPath}`;
|
||||
}}
|
||||
>
|
||||
<Select.Trigger variant="classic" />
|
||||
|
||||
<Select.Content>
|
||||
{SUPPORTED_LOCALES.map((locale) => (
|
||||
{locales.supported.map(({ locale }) => (
|
||||
<Select.Item key={locale} value={locale}>
|
||||
{SUPPORTED_LOCALE_FLAGS[locale]}{' '}
|
||||
{STRINGS[locale].common.locales[locale]}
|
||||
{SUPPORTED_LOCALE_FLAGS[locale]}{" "}
|
||||
{
|
||||
STRINGS[locale].common.locales[
|
||||
locale as keyof BlitzKitStrings["common"]["locales"]
|
||||
]
|
||||
}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select.Content>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Progress } from "@radix-ui/themes";
|
||||
import { Html } from "@react-three/drei";
|
||||
import { useStableProgress } from "../../../hooks/useStableProgress";
|
||||
|
||||
export function MixerFallback() {
|
||||
const progress = useStableProgress();
|
||||
|
||||
return (
|
||||
<Html center>
|
||||
<Progress value={progress} style={{ width: "10rem" }} />
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function Selector({ children }: Props) {
|
||||
return (
|
||||
<Flex align="center">
|
||||
<Box
|
||||
width="16rem"
|
||||
height="1px"
|
||||
style={{ backgroundColor: "var(--gray-12)" }}
|
||||
/>
|
||||
<Box
|
||||
style={{
|
||||
padding: "var(--space-3)",
|
||||
backgroundColor: "var(--gray-3)",
|
||||
borderRadius: "var(--radius-3)",
|
||||
boxShadow: "var(--shadow-3)",
|
||||
}}
|
||||
>
|
||||
<Text style={{ whiteSpace: "nowrap" }}>{children}</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -1,25 +1,35 @@
|
||||
import { OrbitControls } from "@react-three/drei";
|
||||
import { Canvas } from "@react-three/fiber";
|
||||
import { Suspense } from "react";
|
||||
import { forwardRef, Suspense } from "react";
|
||||
import { Lighting } from "../Tankopedia/HeroSection/components/TankSandbox/components/Lighting";
|
||||
import { SceneProps } from "../Tankopedia/HeroSection/components/TankSandbox/components/SceneProps";
|
||||
import { MixerFallback } from "./components/MixerFallback";
|
||||
import { Model } from "./components/Model";
|
||||
|
||||
export function MixerScene() {
|
||||
export const MixerScene = forwardRef<HTMLCanvasElement>((_, ref) => {
|
||||
return (
|
||||
<Canvas
|
||||
ref={ref}
|
||||
shadows="soft"
|
||||
style={{ background: "black" }}
|
||||
camera={{
|
||||
fov: 45,
|
||||
position: [5, 5, -5],
|
||||
position: [-4, 4, -7],
|
||||
}}
|
||||
>
|
||||
<OrbitControls />
|
||||
<OrbitControls
|
||||
maxDistance={20}
|
||||
minDistance={5}
|
||||
enableDamping={false}
|
||||
target={[0, 0.5, 0]}
|
||||
/>
|
||||
|
||||
<Lighting />
|
||||
<SceneProps />
|
||||
|
||||
<Suspense fallback={null}>
|
||||
<Suspense fallback={<MixerFallback />}>
|
||||
<Model />
|
||||
</Suspense>
|
||||
</Canvas>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,24 +1,25 @@
|
||||
---
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import {
|
||||
Cross1Icon,
|
||||
DiscordLogoIcon,
|
||||
GearIcon,
|
||||
HamburgerMenuIcon,
|
||||
} from '@radix-ui/react-icons';
|
||||
import { Box, Code, Flex, IconButton, Link } from '@radix-ui/themes';
|
||||
import { TOOLS } from '../constants/tools';
|
||||
import { resolveBranchName } from '../core/blitzkit/branches';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { Var } from '../core/radix/var';
|
||||
import { LinkI18n } from './LinkI18n';
|
||||
} from "@radix-ui/react-icons";
|
||||
import { Box, Code, Flex, IconButton, Link } from "@radix-ui/themes";
|
||||
import { resolveBranchName } from "../core/blitzkit/branches";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
import { Var } from "../core/radix/var";
|
||||
import { LinkI18n } from "./LinkI18n";
|
||||
import { tools } from "../constants/tools";
|
||||
|
||||
export interface Props {
|
||||
integrated?: boolean;
|
||||
}
|
||||
|
||||
const { integrated = false } = Astro.props;
|
||||
const toolsFiltered = TOOLS.filter((tool) => !('href' in tool));
|
||||
const toolsFiltered = Object.values(tools).filter(
|
||||
(tool) => !tool.href && !tool.disabled
|
||||
);
|
||||
const { locale } = Astro.params;
|
||||
const branchName = resolveBranchName(locale);
|
||||
const isBranchNamed = branchName !== undefined;
|
||||
@@ -39,49 +40,45 @@ const strings = getStrings(locale);
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.navbar[data-expanded='false'] *[data-expanded] {
|
||||
.navbar[data-expanded="false"] *[data-expanded] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navbar[data-expanded='true'] {
|
||||
.navbar[data-expanded="true"] {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.navbar[data-expanded='false'][data-integrated='false'] .content {
|
||||
.navbar[data-expanded="false"][data-integrated="false"] .content {
|
||||
background-color: var(--black-a8);
|
||||
backdrop-filter: blur(4rem);
|
||||
box-shadow: var(--shadow-3);
|
||||
}
|
||||
|
||||
.navbar[data-expanded='true'] .content {
|
||||
.navbar[data-expanded="true"] .content {
|
||||
background-color: var(--gray-1);
|
||||
}
|
||||
|
||||
.navbar[data-expanded='true'] *[data-closed] {
|
||||
.navbar[data-expanded="true"] *[data-closed] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const navbar = document.querySelector<HTMLDivElement>('.navbar');
|
||||
const hamburger = document.querySelector<HTMLButtonElement>('.hamburger');
|
||||
const navbar = document.querySelector<HTMLDivElement>(".navbar");
|
||||
const hamburger = document.querySelector<HTMLButtonElement>(".hamburger");
|
||||
|
||||
navbar?.addEventListener('click', () => {
|
||||
navbar.dataset.expanded = 'false';
|
||||
navbar?.addEventListener("click", () => {
|
||||
navbar.dataset.expanded = "false";
|
||||
});
|
||||
hamburger?.addEventListener('click', (event) => {
|
||||
hamburger?.addEventListener("click", (event) => {
|
||||
if (!navbar) return;
|
||||
|
||||
event.stopPropagation();
|
||||
navbar.dataset.expanded = `${navbar.dataset.expanded === 'false'}`;
|
||||
navbar.dataset.expanded = `${navbar.dataset.expanded === "false"}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
{
|
||||
!integrated && (
|
||||
<Box className="padder" height={{ initial: '3.5rem', sm: '3rem' }} />
|
||||
)
|
||||
}
|
||||
<Box className="padder" height={{ initial: "3.5rem", sm: "3rem" }} />
|
||||
|
||||
<Flex
|
||||
direction="column"
|
||||
@@ -94,16 +91,16 @@ const strings = getStrings(locale);
|
||||
position="fixed"
|
||||
style={{
|
||||
zIndex: 1,
|
||||
backdropFilter: 'blur(4rem)',
|
||||
backdropFilter: "blur(4rem)",
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
className="content"
|
||||
width="100%"
|
||||
p={{ initial: '4', sm: '3' }}
|
||||
p={{ initial: "4", sm: "3" }}
|
||||
direction="column"
|
||||
align="center"
|
||||
style={{ backgroundColor: integrated ? undefined : Var('gray-1') }}
|
||||
style={{ backgroundColor: integrated ? undefined : Var("gray-1") }}
|
||||
>
|
||||
<Flex gap="4" direction="column" maxWidth="80rem" width="100%">
|
||||
<Flex align="center">
|
||||
@@ -131,33 +128,27 @@ const strings = getStrings(locale);
|
||||
|
||||
<Flex
|
||||
align="center"
|
||||
gap={{ initial: '4', md: '6' }}
|
||||
display={{ initial: 'none', sm: 'flex' }}
|
||||
gap={{ initial: "3", md: "6" }}
|
||||
display={{ initial: "none", sm: "flex" }}
|
||||
justify="center"
|
||||
className="tools"
|
||||
>
|
||||
{
|
||||
toolsFiltered.map((tool) => {
|
||||
const unavailableOnBranch = tool.branches?.every(
|
||||
(branch) =>
|
||||
branch !== assertSecret(import.meta.env.PUBLIC_BRANCH),
|
||||
);
|
||||
const selected = Astro.url.pathname.includes(`/${tool.id}`);
|
||||
const toolStrings =
|
||||
strings.website.tools[
|
||||
(tool.stringsId ??
|
||||
(tool.strings ??
|
||||
tool.id) as keyof typeof strings.website.tools
|
||||
];
|
||||
|
||||
if (unavailableOnBranch) return null;
|
||||
|
||||
return (
|
||||
<LinkI18n
|
||||
{locale}
|
||||
weight={selected ? 'medium' : 'regular'}
|
||||
weight={selected ? "medium" : "regular"}
|
||||
color="gray"
|
||||
highContrast={selected}
|
||||
size="2"
|
||||
size={{ initial: "1", md: "2" }}
|
||||
href={`/${tool.id}`}
|
||||
underline="hover"
|
||||
>
|
||||
@@ -172,7 +163,7 @@ const strings = getStrings(locale);
|
||||
|
||||
<Flex align="center" gap="4">
|
||||
<Link
|
||||
style={{ display: 'flex', alignContent: 'center' }}
|
||||
style={{ display: "flex", alignContent: "center" }}
|
||||
color="gray"
|
||||
href="https://discord.gg/nDt7AjGJQH"
|
||||
underline="none"
|
||||
@@ -183,7 +174,7 @@ const strings = getStrings(locale);
|
||||
|
||||
<LinkI18n
|
||||
{locale}
|
||||
style={{ display: 'flex', alignContent: 'center' }}
|
||||
style={{ display: "flex", alignContent: "center" }}
|
||||
color="gray"
|
||||
href="/settings"
|
||||
underline="none"
|
||||
@@ -193,7 +184,7 @@ const strings = getStrings(locale);
|
||||
|
||||
<!-- <NavbarAccount client:idle /> -->
|
||||
|
||||
<Flex align="center" display={{ initial: 'flex', sm: 'none' }}>
|
||||
<Flex align="center" display={{ initial: "flex", sm: "none" }}>
|
||||
<IconButton variant="ghost" color="gray" className="hamburger">
|
||||
<Cross1Icon data-expanded />
|
||||
<HamburgerMenuIcon data-closed />
|
||||
@@ -206,36 +197,28 @@ const strings = getStrings(locale);
|
||||
direction="column"
|
||||
data-expanded
|
||||
gap="3"
|
||||
display={{ initial: 'flex', sm: 'none' }}
|
||||
display={{ initial: "flex", sm: "none" }}
|
||||
>
|
||||
{
|
||||
toolsFiltered.map((tool) => {
|
||||
const unavailableOnBranch = tool.branches?.every(
|
||||
(branch) =>
|
||||
branch !== assertSecret(import.meta.env.PUBLIC_BRANCH),
|
||||
);
|
||||
|
||||
if (unavailableOnBranch) return null;
|
||||
|
||||
toolsFiltered.map(( tool) => {
|
||||
const toolStrings =
|
||||
strings.website.tools[
|
||||
(tool.stringsId ??
|
||||
tool.id) as keyof typeof strings.website.tools
|
||||
(tool.strings ?? tool.id) as keyof typeof strings.website.tools
|
||||
];
|
||||
|
||||
return (
|
||||
<Link
|
||||
color="gray"
|
||||
highContrast
|
||||
style={{ display: 'contents' }}
|
||||
style={{ display: "contents" }}
|
||||
href={`/${tool.id}`}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
borderRadius: Var('radius-2'),
|
||||
borderRadius: Var("radius-2"),
|
||||
backgroundImage: `url(/assets/images/tools/${tool.id}.webp)`,
|
||||
backgroundSize: '200%',
|
||||
backgroundPosition: 'right center',
|
||||
backgroundSize: "200%",
|
||||
backgroundPosition: "right center",
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
@@ -243,7 +226,7 @@ const strings = getStrings(locale);
|
||||
justify="end"
|
||||
flexGrow="1"
|
||||
style={{
|
||||
background: `linear-gradient(90deg, transparent, ${Var('gray-1')} 90%)`,
|
||||
background: `linear-gradient(90deg, transparent, ${Var("gray-1")} 90%)`,
|
||||
}}
|
||||
>
|
||||
{toolStrings.name}
|
||||
@@ -261,11 +244,11 @@ const strings = getStrings(locale);
|
||||
data-expanded
|
||||
flexGrow="1"
|
||||
width="100%"
|
||||
display={{ initial: 'block', sm: 'none' }}
|
||||
display={{ initial: "block", sm: "none" }}
|
||||
style={{
|
||||
backgroundColor: Var('black-a7'),
|
||||
backdropFilter: 'blur(0.5rem)',
|
||||
WebkitBackdropFilter: 'blur(0.5rem)',
|
||||
backgroundColor: Var("black-a7"),
|
||||
backdropFilter: "blur(0.5rem)",
|
||||
WebkitBackdropFilter: "blur(0.5rem)",
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
@@ -1,19 +0,0 @@
|
||||
import {
|
||||
ResponsiveBar,
|
||||
type BarDatum,
|
||||
type ResponsiveBarSvgProps,
|
||||
} from '@nivo/bar';
|
||||
import { nivoTheme } from '../../core/nivo/theme';
|
||||
|
||||
export function ThemedBar<RawDatum extends BarDatum>(
|
||||
props: ResponsiveBarSvgProps<RawDatum>,
|
||||
) {
|
||||
return (
|
||||
<ResponsiveBar
|
||||
colors={{ scheme: 'yellow_green_blue' }}
|
||||
theme={nivoTheme}
|
||||
borderRadius={4}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { ResponsiveLine, type LineSvgProps } from '@nivo/line';
|
||||
import { nivoTheme } from '../../core/nivo/theme';
|
||||
|
||||
export function ThemedLine(props: LineSvgProps) {
|
||||
return (
|
||||
<ResponsiveLine
|
||||
colors={{ scheme: 'yellow_green_blue' }}
|
||||
theme={nivoTheme}
|
||||
margin={{ top: 50, right: 110, bottom: 50, left: 60 }}
|
||||
enablePoints={true}
|
||||
useMesh
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
import { pwaInfo } from "virtual:pwa-info";
|
||||
---
|
||||
|
||||
<script>
|
||||
import { pwaInstallHandler } from "pwa-install-handler";
|
||||
import { registerSW } from "virtual:pwa-register";
|
||||
|
||||
registerSW({
|
||||
immediate: true,
|
||||
|
||||
onRegisterError: console.error,
|
||||
|
||||
onRegisteredSW() {
|
||||
console.log("PWA registered service worker");
|
||||
},
|
||||
|
||||
onOfflineReady() {
|
||||
console.log("PWA offline ready");
|
||||
},
|
||||
|
||||
onNeedRefresh() {
|
||||
document.documentElement.classList.add("pwa-refresh");
|
||||
},
|
||||
});
|
||||
|
||||
pwaInstallHandler.addListener((canInstall) => {
|
||||
document.documentElement.classList.remove(
|
||||
canInstall ? "pwa-disabled" : "pwa-enabled"
|
||||
);
|
||||
document.documentElement.classList.add(
|
||||
canInstall ? "pwa-enabled" : "pwa-disabled"
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
{pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
|
||||
@@ -0,0 +1,136 @@
|
||||
---
|
||||
import { Cross2Icon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Flex,
|
||||
Inset,
|
||||
Link,
|
||||
Spinner,
|
||||
Text,
|
||||
} from "@radix-ui/themes";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
|
||||
type Props = LocaleAcceptorProps & {
|
||||
floating?: boolean;
|
||||
};
|
||||
|
||||
const { locale, floating } = Astro.props;
|
||||
const strings = getStrings(locale);
|
||||
---
|
||||
|
||||
<style>
|
||||
#pwa-prompter[data-floating="true"] {
|
||||
position: fixed;
|
||||
bottom: var(--space-6);
|
||||
right: var(--space-6);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#pwa-prompter[data-floating="true"] .card {
|
||||
box-shadow: var(--shadow-6);
|
||||
}
|
||||
|
||||
.pwa-logo {
|
||||
width: 6rem;
|
||||
height: 6rem;
|
||||
background-image: url(/assets/images/pwa-promo.png);
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
html.pwa-enabled .compatibility-checker,
|
||||
html.pwa-disabled .compatibility-checker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pwa-install,
|
||||
#pwa-incompatible,
|
||||
#pwa-prompter[data-floating="true"],
|
||||
#pwa-dismiss {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html.pwa-enabled #pwa-install,
|
||||
html.pwa-disabled #pwa-incompatible,
|
||||
html.pwa-enabled #pwa-prompter[data-floating="true"],
|
||||
#pwa-prompter[data-floating="true"] #pwa-dismiss {
|
||||
display: unset;
|
||||
}
|
||||
|
||||
.pwa-actions button {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { pwaInstallHandler } from "pwa-install-handler";
|
||||
|
||||
const pwaInstallButton = document.getElementById("pwa-install");
|
||||
const pwaDismissButton = document.getElementById("pwa-dismiss");
|
||||
const pwaPrompter = document.getElementById("pwa-prompter");
|
||||
|
||||
pwaInstallButton?.addEventListener("click", () => {
|
||||
pwaInstallHandler.install();
|
||||
});
|
||||
|
||||
pwaDismissButton?.addEventListener("click", () => {
|
||||
pwaPrompter?.remove();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Flex id="pwa-prompter" justify="center" mt="4" data-floating={floating}>
|
||||
<Card variant="classic" className="card">
|
||||
<Inset>
|
||||
<Flex align="center">
|
||||
<Box className="pwa-logo" />
|
||||
|
||||
<Flex direction="column" gap="2" px="4" py="3">
|
||||
<Flex align="center" gap="2">
|
||||
<Text size="4" weight="medium">
|
||||
{strings.website.home.pwa.title}
|
||||
</Text>
|
||||
<Badge color="jade" variant="outline">
|
||||
{strings.website.home.pwa.new}
|
||||
</Badge>
|
||||
</Flex>
|
||||
|
||||
<Flex className="compatibility-checker" align="center" gap="2">
|
||||
<Spinner />
|
||||
<Text color="gray">
|
||||
{strings.website.home.pwa.checking}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
<Link
|
||||
id="pwa-incompatible"
|
||||
trim="end"
|
||||
underline="always"
|
||||
target="_blank"
|
||||
href="https://www.cdc.gov/niosh/mining/tools/installpwa.html"
|
||||
>
|
||||
{strings.website.home.pwa.instructions}
|
||||
</Link>
|
||||
|
||||
<Flex className="pwa-actions" gap="2">
|
||||
<Button id="pwa-dismiss" color="tomato" variant="outline">
|
||||
<Flex align="center" gap="1" justify="center">
|
||||
<Cross2Icon />
|
||||
{strings.website.home.pwa.dismiss}
|
||||
</Flex>
|
||||
</Button>
|
||||
<Button id="pwa-install" color="jade">
|
||||
<Flex align="center" gap="1" justify="center">
|
||||
<DownloadIcon />
|
||||
{strings.website.home.pwa.install}
|
||||
</Flex>
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Inset>
|
||||
</Card>
|
||||
</Flex>
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Flex, type FlexProps, Theme } from '@radix-ui/themes';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { NAVBAR_HEIGHT } from '../constants/navbar';
|
||||
import type { RadixSize } from '../stores/embedState';
|
||||
import { BlitzKitTheme } from './BlitzKitTheme';
|
||||
import { Flex, type FlexProps, Theme } from "@radix-ui/themes";
|
||||
import type { ComponentProps } from "react";
|
||||
import { NAVBAR_HEIGHT } from "../constants/navbar";
|
||||
import type { RadixSize } from "../stores/embedState";
|
||||
import { BlitzKitTheme } from "./BlitzKitTheme";
|
||||
|
||||
type PageWrapperProps = FlexProps & {
|
||||
color?: ComponentProps<typeof Theme>['accentColor'];
|
||||
color?: ComponentProps<typeof Theme>["accentColor"];
|
||||
containerProps?: ComponentProps<typeof Theme>;
|
||||
noFlex1?: boolean;
|
||||
padding?: RadixSize;
|
||||
@@ -19,7 +19,7 @@ export function PageWrapper({
|
||||
noFlex1 = false,
|
||||
containerProps,
|
||||
noMinHeight = false,
|
||||
padding = '4',
|
||||
padding = "4",
|
||||
...props
|
||||
}: PageWrapperProps) {
|
||||
return (
|
||||
@@ -27,9 +27,9 @@ export function PageWrapper({
|
||||
accentColor={color}
|
||||
style={{
|
||||
flex: noFlex1 ? undefined : 1,
|
||||
display: 'flex',
|
||||
minHeight: noMinHeight ? 'unset' : `calc(100svh - ${NAVBAR_HEIGHT}px)`,
|
||||
flexDirection: 'column',
|
||||
display: "flex",
|
||||
minHeight: noMinHeight ? "unset" : `calc(100svh - ${NAVBAR_HEIGHT}px)`,
|
||||
flexDirection: "column",
|
||||
...containerProps?.style,
|
||||
}}
|
||||
{...containerProps}
|
||||
@@ -41,8 +41,8 @@ export function PageWrapper({
|
||||
width="100%"
|
||||
maxWidth="80rem"
|
||||
style={{
|
||||
margin: 'auto',
|
||||
boxSizing: 'border-box',
|
||||
margin: "auto",
|
||||
boxSizing: "border-box",
|
||||
flex: 1,
|
||||
...style,
|
||||
}}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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 { 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";
|
||||
|
||||
interface RowLoaderProps {
|
||||
onIntersection?: () => void;
|
||||
}
|
||||
|
||||
export const RowLoader = memo<RowLoaderProps>(({ onIntersection }) => {
|
||||
const row = useRef<HTMLTableRowElement>(null);
|
||||
const row = useRef<HTMLTableRowElement>(null!);
|
||||
|
||||
useIntersection(() => onIntersection?.(), row, {
|
||||
disabled: onIntersection === undefined,
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { CameraIcon, CopyIcon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Button,
|
||||
Flex,
|
||||
IconButton,
|
||||
Popover,
|
||||
type ButtonProps,
|
||||
} from "@radix-ui/themes";
|
||||
import type { RefObject } from "react";
|
||||
import { useLocale } from "../hooks/useLocale";
|
||||
import { screenshotReadyEvent } from "./Tankopedia/HeroSection/components/TankSandbox/components/SceneProps";
|
||||
|
||||
interface Props extends ButtonProps {
|
||||
canvas: RefObject<HTMLCanvasElement>;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<Popover.Root>
|
||||
<Popover.Trigger>
|
||||
{children ? (
|
||||
<Button {...props}>
|
||||
<CameraIcon />
|
||||
{children}
|
||||
</Button>
|
||||
) : (
|
||||
<IconButton {...props}>
|
||||
<CameraIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>
|
||||
<Flex direction="column" gap="2">
|
||||
<Popover.Close>
|
||||
<Button
|
||||
onClick={() => {
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!canvas.current) return;
|
||||
|
||||
const anchor = document.createElement("a");
|
||||
|
||||
anchor.setAttribute("download", `${name}.png`);
|
||||
anchor.setAttribute(
|
||||
"href",
|
||||
canvas.current.toDataURL("image/png")
|
||||
);
|
||||
anchor.click();
|
||||
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<DownloadIcon />
|
||||
{strings.website.tools.tankopedia.sandbox.screenshot.download}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
<Popover.Close>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!canvas.current) return;
|
||||
|
||||
canvas.current.toBlob((blob) => {
|
||||
if (!blob) return;
|
||||
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({ "image/png": blob }),
|
||||
]);
|
||||
});
|
||||
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
{strings.website.tools.tankopedia.sandbox.screenshot.copy}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
</Flex>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
);
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
import { Canvas, type CanvasProps } from '@react-three/fiber';
|
||||
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
||||
import { useOnScreen } from '../hooks/useOnScreen';
|
||||
import { Canvas, type CanvasProps } from "@react-three/fiber";
|
||||
import { forwardRef, useImperativeHandle, useRef } from "react";
|
||||
import { useOnScreen } from "../hooks/useOnScreen";
|
||||
|
||||
export const SmartCanvas = forwardRef<HTMLCanvasElement, CanvasProps>(
|
||||
(props, ref) => {
|
||||
const canvas = useRef<HTMLCanvasElement>(null);
|
||||
const canvas = useRef<HTMLCanvasElement>(null!);
|
||||
const onScreen = useOnScreen(canvas);
|
||||
|
||||
useImperativeHandle(ref, () => canvas.current!, []);
|
||||
|
||||
return (
|
||||
<Canvas
|
||||
frameloop={onScreen ? 'demand' : 'never'}
|
||||
frameloop={onScreen ? "demand" : "never"}
|
||||
ref={canvas}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Flex, Skeleton } from '@radix-ui/themes';
|
||||
import { memo, useRef } from 'react';
|
||||
import { useIntersection } from '../../../hooks/useIntersection';
|
||||
import { Flex, Skeleton } from "@radix-ui/themes";
|
||||
import { memo, useRef } from "react";
|
||||
import { useIntersection } from "../../../hooks/useIntersection";
|
||||
|
||||
interface SkeletonTankCardProps {
|
||||
onIntersection?: () => void;
|
||||
@@ -8,7 +8,7 @@ interface SkeletonTankCardProps {
|
||||
|
||||
export const SkeletonTankCard = memo(
|
||||
({ onIntersection }: SkeletonTankCardProps) => {
|
||||
const card = useRef<HTMLDivElement>(null);
|
||||
const card = useRef<HTMLDivElement>(null!);
|
||||
|
||||
useIntersection(() => onIntersection?.(), card, {
|
||||
disabled: onIntersection === undefined,
|
||||
@@ -21,5 +21,5 @@ export const SkeletonTankCard = memo(
|
||||
</Flex>
|
||||
);
|
||||
},
|
||||
() => true,
|
||||
() => true
|
||||
);
|
||||
@@ -1,13 +1,10 @@
|
||||
import { Grid, type GridProps } from '@radix-ui/themes';
|
||||
import { Grid, type GridProps } from "@radix-ui/themes";
|
||||
|
||||
export function TankCardWrapper(props: GridProps) {
|
||||
return (
|
||||
<Grid
|
||||
py="4"
|
||||
columns={{
|
||||
initial: 'repeat(auto-fill, minmax(6rem, 1fr))',
|
||||
sm: 'repeat(auto-fill, minmax(10rem, 1fr))',
|
||||
}}
|
||||
columns="repeat(auto-fill, minmax(7rem, 1fr))"
|
||||
flow="dense"
|
||||
gap="4"
|
||||
gapY="8"
|
||||
|
||||
@@ -33,7 +33,7 @@ import { SkeletonTankCard } from "./components/SkeletonTankCard";
|
||||
import { TankCardWrapper } from "./components/TankCardWrapper";
|
||||
import { MAX_RECENTLY_VIEWED } from "./constants";
|
||||
|
||||
type TankSearchProps = MaybeSkeletonComponentProps &
|
||||
export type TankSearchProps = MaybeSkeletonComponentProps &
|
||||
Omit<FlexProps, "onSelect"> & {
|
||||
compact?: boolean;
|
||||
onSelect?: (tank: TankDefinition) => void;
|
||||
|
||||
@@ -38,7 +38,7 @@ export function Info({
|
||||
const result = fuzzysort.single(statSearch, name);
|
||||
|
||||
if (result) {
|
||||
label = fuzzysort.highlight(result, (match, index) => (
|
||||
label = result.highlight((match, index) => (
|
||||
<Mark key={index}>{match}</Mark>
|
||||
));
|
||||
highlighted = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Flex, Link, Text } from '@radix-ui/themes';
|
||||
import { Var } from '../../../core/radix/var';
|
||||
import type { TankGuide } from '../../../pages/[...locale]/tanks/[slug]/index.astro';
|
||||
import { CaretRightIcon } from "@radix-ui/react-icons";
|
||||
import { Box, Flex, Link, Text } from "@radix-ui/themes";
|
||||
import { Var } from "../../../core/radix/var";
|
||||
import type { TankGuide } from "../../../pages/[...locale]/tanks/[slug]/index.astro";
|
||||
|
||||
interface Props {
|
||||
guide: TankGuide;
|
||||
@@ -16,10 +16,10 @@ export function GuideSection({ guide }: Props) {
|
||||
underline="none"
|
||||
highContrast
|
||||
style={{
|
||||
display: 'flex',
|
||||
maxWidth: '35rem',
|
||||
flexDirection: 'column',
|
||||
gap: Var('space-4'),
|
||||
display: "flex",
|
||||
maxWidth: "35rem",
|
||||
flexDirection: "column",
|
||||
gap: Var("space-4"),
|
||||
}}
|
||||
>
|
||||
<Flex maxWidth="35rem" direction="column" gap="4">
|
||||
@@ -28,9 +28,9 @@ export function GuideSection({ guide }: Props) {
|
||||
<Flex width="100%" justify="start" align="center" gap="2">
|
||||
<img
|
||||
style={{
|
||||
width: '1.5em',
|
||||
height: '1.5em',
|
||||
objectFit: 'contain',
|
||||
width: "1.5em",
|
||||
height: "1.5em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src="https://guidesblitz.com/wp-content/uploads/2023/11/cropped-logo-1.png"
|
||||
/>
|
||||
@@ -39,7 +39,7 @@ export function GuideSection({ guide }: Props) {
|
||||
</Text>
|
||||
|
||||
<Text size="2">{guide.description}</Text>
|
||||
<img style={{ width: '100%' }} src={guide.image} />
|
||||
<img style={{ width: "100%" }} src={guide.image} />
|
||||
|
||||
<Box
|
||||
position="absolute"
|
||||
@@ -48,7 +48,7 @@ export function GuideSection({ guide }: Props) {
|
||||
height="100%"
|
||||
left="0"
|
||||
style={{
|
||||
background: `linear-gradient(${Var('gray-a1')}, ${Var('gray-1')})`,
|
||||
background: `linear-gradient(${Var("gray-a1")}, ${Var("gray-1")})`,
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
@@ -6,9 +6,6 @@ import {
|
||||
} from "@blitzkit/core";
|
||||
import { literals } from "@blitzkit/i18n/src/literals";
|
||||
import {
|
||||
CameraIcon,
|
||||
CopyIcon,
|
||||
DownloadIcon,
|
||||
EnterFullScreenIcon,
|
||||
ExitFullScreenIcon,
|
||||
EyeOpenIcon,
|
||||
@@ -39,9 +36,9 @@ import { TankopediaDisplay } from "../../../../../stores/tankopediaPersistent/co
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps";
|
||||
import type { ThicknessRange } from "../../../../Armor/components/StaticArmor";
|
||||
import { ModuleButton } from "../../../../ModuleButtons/ModuleButton";
|
||||
import { ScreenshotButton } from "../../../../ScreenshotButton";
|
||||
import { SmallTankIcon } from "../../../../SmallTankIcon";
|
||||
import { TankSearch } from "../../../../TankSearch";
|
||||
import { screenshotReadyEvent } from "../TankSandbox/components/SceneProps";
|
||||
import { CustomShellButton } from "./components/CustomShellButton";
|
||||
import { DynamicArmorSwitcher } from "./components/DynamicArmorSwitcher";
|
||||
import { QuickInputs } from "./components/QuickInputs";
|
||||
@@ -331,7 +328,9 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) {
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Content>
|
||||
<Dialog.Title align="center">Select tank</Dialog.Title>
|
||||
<Dialog.Title align="center">
|
||||
{strings.website.common.tank_search.select_dialog_title}
|
||||
</Dialog.Title>
|
||||
|
||||
<Tabs.Root
|
||||
value={tab}
|
||||
@@ -438,77 +437,12 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) {
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
|
||||
<Popover.Root>
|
||||
<Popover.Trigger>
|
||||
<IconButton color="gray" variant="ghost">
|
||||
<CameraIcon />
|
||||
</IconButton>
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>
|
||||
<Flex direction="column" gap="2">
|
||||
<Popover.Close>
|
||||
<Button
|
||||
onClick={() => {
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!canvas.current) return;
|
||||
|
||||
const anchor = document.createElement("a");
|
||||
|
||||
anchor.setAttribute(
|
||||
"download",
|
||||
`${protagonistTank.name}.png`
|
||||
);
|
||||
anchor.setAttribute(
|
||||
"href",
|
||||
canvas.current.toDataURL("image/png")
|
||||
);
|
||||
anchor.click();
|
||||
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<DownloadIcon />
|
||||
{
|
||||
strings.website.tools.tankopedia.sandbox.screenshot
|
||||
.download
|
||||
}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
<Popover.Close>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!canvas.current) return;
|
||||
|
||||
canvas.current.toBlob((blob) => {
|
||||
if (!blob) return;
|
||||
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({ "image/png": blob }),
|
||||
]);
|
||||
});
|
||||
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
{
|
||||
strings.website.tools.tankopedia.sandbox.screenshot
|
||||
.copy
|
||||
}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
</Flex>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
<ScreenshotButton
|
||||
color="gray"
|
||||
variant="ghost"
|
||||
canvas={canvas}
|
||||
name={protagonistTank.slug}
|
||||
/>
|
||||
|
||||
{fullScreenAvailable && (
|
||||
<IconButton
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Box, Progress } from '@radix-ui/themes';
|
||||
import { useProgress } from '@react-three/drei';
|
||||
import { Box, Progress } from "@radix-ui/themes";
|
||||
import { useStableProgress } from "../../../../../../../hooks/useStableProgress";
|
||||
|
||||
interface Props {
|
||||
fontSize?: string;
|
||||
}
|
||||
|
||||
export function Tracker({ fontSize }: Props) {
|
||||
const { loaded, total } = useProgress();
|
||||
const progress = total === 0 ? 0 : (loaded / total) * 100;
|
||||
const progress = useStableProgress();
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
||||
@@ -266,7 +266,6 @@ export function Controls({
|
||||
ref={orbitControls}
|
||||
enabled={Tankopedia.state.controlsEnabled}
|
||||
enableDamping={false}
|
||||
autoRotateSpeed={1 / 4}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { useRef, useState } from "react";
|
||||
import { Color, SpotLight, SpotLightHelper } from "three";
|
||||
import { degToRad } from "three/src/math/MathUtils.js";
|
||||
import { isHalloween } from "../../../../../../core/blitzkit/isHalloween";
|
||||
import { Tankopedia } from "../../../../../../stores/tankopedia";
|
||||
import { HelpingSpotLight } from "../../../../../HelpingSpotLight";
|
||||
|
||||
const LIGHTS_COUNT = 5;
|
||||
@@ -18,6 +19,7 @@ const TARGET_FRAME_RATE = 30;
|
||||
|
||||
export function Lighting() {
|
||||
const [cast, setCast] = useState(true);
|
||||
const revealed = Tankopedia.use((state) => state.revealed);
|
||||
|
||||
const topLight = useRef<SpotLight>(null!);
|
||||
const frontLight = useRef<SpotLight>(null!);
|
||||
@@ -29,7 +31,7 @@ export function Lighting() {
|
||||
const samples = useRef<number[]>([]);
|
||||
|
||||
useFrame(({ clock }) => {
|
||||
if (!cast) return;
|
||||
if (!cast || !revealed) return;
|
||||
|
||||
const dt = clock.elapsedTime - last.current;
|
||||
last.current = clock.elapsedTime;
|
||||
@@ -61,6 +63,7 @@ export function Lighting() {
|
||||
|
||||
return (
|
||||
<HelpingSpotLight
|
||||
key={index}
|
||||
position={position}
|
||||
intensity={INTENSITY}
|
||||
penumbra={1}
|
||||
|
||||
@@ -19,8 +19,8 @@ export function TankModel() {
|
||||
const turret = Duel.use((state) => state.protagonist.turret);
|
||||
const canvas = useThree((state) => state.gl.domElement);
|
||||
const hullContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null);
|
||||
const gunContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null!);
|
||||
const gunContainer = useRef<Group>(null!);
|
||||
const tankModelDefinition = useTankModelDefinition();
|
||||
const turretModelDefinition =
|
||||
tankModelDefinition.turrets[protagonist.turret.id];
|
||||
|
||||
@@ -26,8 +26,8 @@ export function TransitionSkeleton() {
|
||||
const gun = Duel.use((state) => state.protagonist.gun);
|
||||
const track = Duel.use((state) => state.protagonist.track);
|
||||
const turret = Duel.use((state) => state.protagonist.turret);
|
||||
const turretContainer = useRef<Group>(null);
|
||||
const gunContainer = useRef<Group>(null);
|
||||
const turretContainer = useRef<Group>(null!);
|
||||
const gunContainer = useRef<Group>(null!);
|
||||
const { gltf: armorGltf } = useArmor(tank.id);
|
||||
const { gltf: modelGltf } = useModel(tank.id);
|
||||
const modelNodes = Object.values(modelGltf.nodes);
|
||||
|
||||
@@ -16,7 +16,7 @@ const tankDefinitions = await awaitableTankDefinitions;
|
||||
export function HeroSection({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
const revealed = Tankopedia.use((state) => state.revealed);
|
||||
const disturbed = Tankopedia.use((state) => state.disturbed);
|
||||
const canvas = useRef<HTMLCanvasElement>(null);
|
||||
const canvas = useRef<HTMLCanvasElement>(null!);
|
||||
const isFullScreen = useFullScreen();
|
||||
const protagonist = Duel.use((state) => state.protagonist.tank);
|
||||
const thicknessRange = useMemo(() => {
|
||||
@@ -99,10 +99,10 @@ export function HeroSection({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
isFullScreen
|
||||
? "100vh"
|
||||
: disturbed
|
||||
? "calc(100svh - 6rem)"
|
||||
? "calc(100svh - 8rem)"
|
||||
: {
|
||||
initial: "28rem",
|
||||
md: "calc(100svh - 12rem)",
|
||||
md: "calc(100svh - 14rem)",
|
||||
}
|
||||
}
|
||||
maxWidth={isFullScreen ? undefined : "120rem"}
|
||||
@@ -140,7 +140,9 @@ export function HeroSection({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
}}
|
||||
>
|
||||
<Suspense>
|
||||
<TankSandbox ref={canvas} thicknessRange={thicknessRange} />
|
||||
{!skeleton && (
|
||||
<TankSandbox ref={canvas} thicknessRange={thicknessRange} />
|
||||
)}
|
||||
</Suspense>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
---
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Button, Code, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import type { Tool } from '../constants/tools';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { LinkI18n } from './LinkI18n';
|
||||
import { CaretRightIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Flex,
|
||||
Heading,
|
||||
Text,
|
||||
type ButtonProps,
|
||||
} from "@radix-ui/themes";
|
||||
import type { Tool } from "../constants/tools";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
import { LinkI18n } from "./LinkI18n";
|
||||
|
||||
interface Props {
|
||||
tool: Tool;
|
||||
}
|
||||
|
||||
const { tool } = Astro.props;
|
||||
const disabled = tool.branches?.every(
|
||||
(branch) => branch !== assertSecret(import.meta.env.PUBLIC_BRANCH),
|
||||
);
|
||||
const { locale } = Astro.params;
|
||||
const strings = getStrings(locale);
|
||||
const toolStrings =
|
||||
strings.website.tools[
|
||||
(tool.stringsId ?? tool.id) as keyof typeof strings.website.tools
|
||||
(tool.strings ?? tool.id) as keyof typeof strings.website.tools
|
||||
];
|
||||
---
|
||||
|
||||
@@ -29,11 +32,12 @@ const toolStrings =
|
||||
background-position: center;
|
||||
height: 16rem;
|
||||
|
||||
&[data-disabled='true'] {
|
||||
&[data-disabled="true"] {
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
&[data-significant='true'] {
|
||||
&[data-significant="true"] {
|
||||
width: 100%;
|
||||
height: min(20rem, 50vh);
|
||||
}
|
||||
}
|
||||
@@ -48,91 +52,78 @@ const toolStrings =
|
||||
</style>
|
||||
|
||||
<Flex
|
||||
style={{ backgroundImage: `url(/assets/images/tools/${tool.id}.webp)` }}
|
||||
data-disabled={disabled}
|
||||
style={{
|
||||
backgroundImage: `url(/assets/images/tools/${tool.id}.webp)`,
|
||||
}}
|
||||
data-significant={tool.significant}
|
||||
className="container"
|
||||
position="relative"
|
||||
overflow="hidden"
|
||||
flexGrow={tool.significant ? undefined : '1'}
|
||||
flexBasis={tool.significant ? undefined : { initial: undefined, sm: '0' }}
|
||||
flexGrow={tool.significant ? undefined : "1"}
|
||||
flexBasis={tool.significant ? undefined : { initial: undefined, sm: "0" }}
|
||||
>
|
||||
<LinkI18n
|
||||
{locale}
|
||||
className="link"
|
||||
underline="none"
|
||||
href={disabled ? '#' : (tool.href ?? `/${tool.id}`)}
|
||||
target={tool.href ? '_blank' : undefined}
|
||||
href={tool.href ?? `/${tool.id}`}
|
||||
target={tool.href ? "_blank" : undefined}
|
||||
>
|
||||
<Box
|
||||
flexGrow="1"
|
||||
style={{
|
||||
backgroundImage: `url(/assets/images/tools/${tool.id}.webp)`,
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
backgroundSize: "cover",
|
||||
backgroundPosition: "center",
|
||||
}}
|
||||
/>
|
||||
|
||||
<Flex
|
||||
px={{ initial: '6', md: tool.significant ? '8' : '6' }}
|
||||
py={{ initial: '4', sm: tool.significant ? '6' : '4' }}
|
||||
px={{ initial: "6", md: tool.significant ? "8" : "6" }}
|
||||
py={{ initial: "4", sm: tool.significant ? "6" : "4" }}
|
||||
gap="4"
|
||||
align="center"
|
||||
justify="between"
|
||||
width="100%"
|
||||
direction={{ initial: 'column', xs: 'row' }}
|
||||
direction={{ initial: "column", xs: "row" }}
|
||||
style={{
|
||||
backgroundColor: 'var(--color-panel-translucent)',
|
||||
backdropFilter: 'blur(64px)',
|
||||
WebkitBackdropFilter: 'blur(64px)',
|
||||
backgroundColor: "var(--color-panel-translucent)",
|
||||
backdropFilter: "blur(64px)",
|
||||
WebkitBackdropFilter: "blur(64px)",
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
direction="column"
|
||||
justify="center"
|
||||
align={{ initial: 'center', xs: 'start' }}
|
||||
align={{ initial: "center", xs: "start" }}
|
||||
>
|
||||
<Heading
|
||||
align={{ initial: 'center', sm: 'left' }}
|
||||
size={{ initial: '6', sm: tool.significant ? '7' : '5' }}
|
||||
align={{ initial: "center", sm: "left" }}
|
||||
size={{ initial: "6", sm: tool.significant ? "7" : "5" }}
|
||||
weight="medium"
|
||||
>
|
||||
{toolStrings.name}
|
||||
</Heading>
|
||||
<Text
|
||||
align={{ initial: 'center', sm: 'left' }}
|
||||
size={{ initial: '3', sm: tool.significant ? '4' : '3' }}
|
||||
align={{ initial: "center", sm: "left" }}
|
||||
size={{ initial: "3", sm: tool.significant ? "4" : "3" }}
|
||||
color="gray"
|
||||
>
|
||||
{
|
||||
disabled ? (
|
||||
<>
|
||||
Unavailable on{' '}
|
||||
<Code>{assertSecret(import.meta.env.PUBLIC_BRANCH)}</Code>
|
||||
</>
|
||||
) : (
|
||||
toolStrings.description
|
||||
)
|
||||
}
|
||||
{toolStrings.description}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
{
|
||||
!disabled && (
|
||||
<Button
|
||||
highContrast={tool.button.highContrast}
|
||||
size={{
|
||||
initial: undefined,
|
||||
sm: tool.significant ? '3' : undefined,
|
||||
}}
|
||||
color={tool.button.color}
|
||||
style={{ cursor: 'inherit' }}
|
||||
>
|
||||
{toolStrings.button}
|
||||
<CaretRightIcon />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
<Button
|
||||
size={{
|
||||
initial: undefined,
|
||||
sm: tool.significant ? "3" : undefined,
|
||||
}}
|
||||
color={tool.button as ButtonProps["color"]}
|
||||
style={{ cursor: "inherit" }}
|
||||
>
|
||||
{toolStrings.button}
|
||||
<CaretRightIcon />
|
||||
</Button>
|
||||
</Flex>
|
||||
</LinkI18n>
|
||||
</Flex>
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import { AstroSeo } from '@astrolib/seo';
|
||||
import { type Tool } from '../constants/tools';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import type { Tool } from "../constants/tools";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
|
||||
interface Props {
|
||||
tool: Tool;
|
||||
@@ -12,7 +12,7 @@ const { locale } = Astro.params;
|
||||
const strings = getStrings(locale);
|
||||
const toolStrings =
|
||||
strings.website.tools[
|
||||
(tool.stringsId ?? tool.id) as keyof typeof strings.website.tools
|
||||
(tool.strings ?? tool.id) as keyof typeof strings.website.tools
|
||||
];
|
||||
---
|
||||
|
||||
@@ -23,11 +23,13 @@ const toolStrings =
|
||||
openGraph={{
|
||||
url: Astro.url.href,
|
||||
images: [
|
||||
{ url: `${Astro.url.origin}/assets/images/tools/${tool.id}.webp` },
|
||||
{
|
||||
url: `${Astro.url.origin}/assets/images/tools/${tool.id}.webp`,
|
||||
},
|
||||
],
|
||||
title: toolStrings.name,
|
||||
description: toolStrings.seo_description,
|
||||
site_name: 'BlitzKit',
|
||||
site_name: "BlitzKit",
|
||||
}}
|
||||
twitter={{ cardType: 'summary_large_image' }}
|
||||
twitter={{ cardType: "summary_large_image" }}
|
||||
/>
|
||||
@@ -1,8 +1,8 @@
|
||||
import { getAccountInfo, idToRegion } from '@blitzkit/core';
|
||||
import { Text } from '@radix-ui/themes';
|
||||
import { useMemo } from 'react';
|
||||
import usePromise from 'react-promise-suspense';
|
||||
import { App } from '../stores/app';
|
||||
import { getAccountInfo, idToRegion } from "@blitzkit/core";
|
||||
import { Text } from "@radix-ui/themes";
|
||||
import { useMemo } from "react";
|
||||
import usePromise from "react-promise-suspense";
|
||||
import { App } from "../stores/app";
|
||||
|
||||
export function WargamingAccountName() {
|
||||
const wargaming = App.use((state) => state.logins.wargaming);
|
||||
@@ -13,7 +13,7 @@ export function WargamingAccountName() {
|
||||
idToRegion(wargaming.id),
|
||||
wargaming.id,
|
||||
[],
|
||||
{ access_token: wargaming.token },
|
||||
{ access_token: wargaming.token }
|
||||
);
|
||||
|
||||
return data?.nickname as string | undefined;
|
||||
|
||||
@@ -1,148 +1,78 @@
|
||||
import { Button } from '@radix-ui/themes';
|
||||
import type { ComponentProps } from 'react';
|
||||
import type { ButtonProps } from "@radix-ui/themes";
|
||||
|
||||
export interface Tool {
|
||||
id: string;
|
||||
stringsId?: string;
|
||||
strings?: string;
|
||||
|
||||
button: ButtonProps["color"];
|
||||
significant?: boolean;
|
||||
disabled?: boolean;
|
||||
href?: string;
|
||||
button: {
|
||||
highContrast?: boolean;
|
||||
color: ComponentProps<typeof Button>['color'];
|
||||
};
|
||||
significant?: boolean;
|
||||
branches?: string[];
|
||||
}
|
||||
|
||||
export const tankopediaTool: Tool = {
|
||||
id: 'tanks',
|
||||
stringsId: 'tankopedia',
|
||||
button: {
|
||||
color: 'purple',
|
||||
export const tools: Record<string, Tool> = {
|
||||
tanks: {
|
||||
id: "tanks",
|
||||
strings: "tankopedia",
|
||||
button: "purple",
|
||||
significant: true,
|
||||
},
|
||||
significant: true,
|
||||
branches: ['main', 'dev', 'opentest', 'preview'],
|
||||
};
|
||||
|
||||
// export const ratingTool: Tool = {
|
||||
// id: 'rating',
|
||||
// image: 'WEyMZH3',
|
||||
// button: {
|
||||
// color: 'orange',
|
||||
// },
|
||||
// branches: ['main', 'dev'],
|
||||
// };
|
||||
|
||||
export const compareTool: Tool = {
|
||||
id: 'compare',
|
||||
button: {
|
||||
color: 'crimson',
|
||||
players: {
|
||||
id: "players",
|
||||
disabled: true,
|
||||
button: "blue",
|
||||
},
|
||||
branches: ['main', 'dev', 'opentest', 'preview'],
|
||||
};
|
||||
|
||||
export const sessionTool: Tool = {
|
||||
// TODO: rename to tracker
|
||||
id: 'session',
|
||||
button: {
|
||||
color: 'blue',
|
||||
compare: {
|
||||
id: "compare",
|
||||
button: "crimson",
|
||||
},
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const discordTool: Tool = {
|
||||
id: 'discord',
|
||||
href: 'https://discord.com/application-directory/1097673957865443370',
|
||||
button: {
|
||||
color: 'indigo',
|
||||
performance: {
|
||||
id: "performance",
|
||||
button: "jade",
|
||||
},
|
||||
charts: {
|
||||
id: "charts",
|
||||
disabled: true,
|
||||
button: "bronze",
|
||||
},
|
||||
guess: {
|
||||
id: "guess",
|
||||
button: "cyan",
|
||||
},
|
||||
mixer: {
|
||||
id: "mixer",
|
||||
button: "gray",
|
||||
},
|
||||
gallery: {
|
||||
id: "gallery",
|
||||
button: "gold",
|
||||
},
|
||||
session: {
|
||||
id: "session",
|
||||
button: "blue",
|
||||
},
|
||||
discord: {
|
||||
id: "discord",
|
||||
href: "https://discord.com/application-directory/1097673957865443370",
|
||||
button: "indigo",
|
||||
},
|
||||
tier_list: {
|
||||
id: "tier-list",
|
||||
strings: "tier_list",
|
||||
button: "orange",
|
||||
},
|
||||
embed: {
|
||||
id: "embed",
|
||||
button: "red",
|
||||
},
|
||||
api: {
|
||||
id: "api",
|
||||
disabled: true,
|
||||
button: "bronze",
|
||||
},
|
||||
more: {
|
||||
id: "more",
|
||||
href: "https://discord.gg/nDt7AjGJQH",
|
||||
button: "plum",
|
||||
},
|
||||
};
|
||||
|
||||
export const moreTool: Tool = {
|
||||
id: 'more',
|
||||
href: 'https://discord.gg/nDt7AjGJQH',
|
||||
button: {
|
||||
color: 'plum',
|
||||
},
|
||||
};
|
||||
|
||||
export const playersTool: Tool = {
|
||||
id: 'players',
|
||||
button: {
|
||||
color: 'blue',
|
||||
},
|
||||
href: '_', // TODO: remove this to re-enable link
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const performanceTool: Tool = {
|
||||
id: 'performance',
|
||||
button: {
|
||||
color: 'jade',
|
||||
},
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const embedTool: Tool = {
|
||||
id: 'embed',
|
||||
button: {
|
||||
color: 'red',
|
||||
},
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const homeTool: Tool = {
|
||||
id: 'home',
|
||||
button: { color: 'blue' },
|
||||
};
|
||||
|
||||
export const galleryTool: Tool = {
|
||||
id: 'gallery',
|
||||
button: {
|
||||
color: 'gold',
|
||||
},
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const tierListTool: Tool = {
|
||||
id: 'tier-list',
|
||||
stringsId: 'tier_list',
|
||||
button: {
|
||||
color: 'orange',
|
||||
},
|
||||
branches: ['main', 'dev', 'opentest', 'preview'],
|
||||
};
|
||||
|
||||
export const chartsTool: Tool = {
|
||||
id: 'charts',
|
||||
button: {
|
||||
color: 'bronze',
|
||||
},
|
||||
branches: ['main', 'dev'],
|
||||
};
|
||||
|
||||
export const guessTool: Tool = {
|
||||
id: 'guess',
|
||||
button: { color: 'cyan' },
|
||||
branches: ['main', 'dev', 'opentest', 'preview'],
|
||||
};
|
||||
|
||||
export const mixerTool: Tool = {
|
||||
id: 'mixer',
|
||||
button: { color: 'red' },
|
||||
branches: ['main', 'dev', 'opentest', 'preview'],
|
||||
};
|
||||
|
||||
export const TOOLS: Tool[] = [
|
||||
tankopediaTool,
|
||||
compareTool,
|
||||
performanceTool,
|
||||
guessTool,
|
||||
// mixerTool,
|
||||
// chartsTool,
|
||||
galleryTool,
|
||||
sessionTool,
|
||||
tierListTool,
|
||||
embedTool,
|
||||
// ratingTool,
|
||||
];
|
||||
@@ -1,15 +1,16 @@
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import { DEFAULT_LOCALE, STRINGS, type SupportedLocale } from '@blitzkit/i18n';
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import { STRINGS } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
|
||||
export function resolveBranchName(locale: string = DEFAULT_LOCALE) {
|
||||
export function resolveBranchName(locale: string = locales.default) {
|
||||
if (!(locale in STRINGS)) throw new Error(`Unsupported locale: ${locale}`);
|
||||
|
||||
const strings = STRINGS[locale as SupportedLocale];
|
||||
const strings = STRINGS[locale];
|
||||
const secret = assertSecret(import.meta.env.PUBLIC_BRANCH);
|
||||
|
||||
if (
|
||||
assertSecret(import.meta.env.MODE) === 'development' &&
|
||||
secret === 'dev'
|
||||
assertSecret(import.meta.env.MODE) === "development" &&
|
||||
secret === "dev"
|
||||
) {
|
||||
return strings.common.branches.local;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { awaitableModelDefinitions } from "../awaitables/modelDefinitions";
|
||||
import { awaitableTankDefinitions } from "../awaitables/tankDefinitions";
|
||||
|
||||
const tankDefinitions = await awaitableTankDefinitions;
|
||||
const modelDefinitions = await awaitableModelDefinitions;
|
||||
const tanks = Object.values(tankDefinitions.tanks).filter((tank) => {
|
||||
const tankModel = modelDefinitions.models[tank.id];
|
||||
const turret = tank.turrets.at(-1)!;
|
||||
const turretModel = tankModel.turrets[turret.id];
|
||||
|
||||
return tank.tier >= 10 && !turretModel.yaw;
|
||||
});
|
||||
|
||||
export function curateMixer() {
|
||||
const hull = tanks[Math.floor(Math.random() * tanks.length)];
|
||||
const turretTank = tanks[Math.floor(Math.random() * tanks.length)];
|
||||
const turret =
|
||||
turretTank.turrets[Math.floor(Math.random() * turretTank.turrets.length)];
|
||||
const gunTank = tanks[Math.floor(Math.random() * tanks.length)];
|
||||
const gunTurret =
|
||||
gunTank.turrets[Math.floor(Math.random() * gunTank.turrets.length)];
|
||||
const gun = gunTurret.guns[Math.floor(Math.random() * gunTurret.guns.length)];
|
||||
|
||||
return {
|
||||
hull: hull,
|
||||
turret: { tank: turretTank, turret: turret },
|
||||
gun: {
|
||||
tank: gunTank,
|
||||
turret: gunTurret,
|
||||
gun: gun,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,20 @@
|
||||
import type { GroupProps, MeshProps } from '@react-three/fiber';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Mesh, Object3D } from 'three';
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { Mesh, Object3D } from "three";
|
||||
|
||||
export function jsxTree(
|
||||
node: Object3D,
|
||||
mergers?: {
|
||||
mesh?: (mesh: Mesh, props: MeshProps, key: string) => ReactNode;
|
||||
group?: (object3d: Object3D, props: GroupProps, key: string) => ReactNode;
|
||||
},
|
||||
mesh?: (
|
||||
mesh: Mesh,
|
||||
props: ComponentProps<"mesh">,
|
||||
key: string
|
||||
) => ReactNode;
|
||||
group?: (
|
||||
object3d: Object3D,
|
||||
props: ComponentProps<"group">,
|
||||
key: string
|
||||
) => ReactNode;
|
||||
}
|
||||
): ReactNode {
|
||||
if (node instanceof Mesh) {
|
||||
const props = {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
|
||||
export function getBestLocale() {
|
||||
const desiredLocale =
|
||||
localStorage.getItem('preferred-locale') ??
|
||||
navigator.language.split('-')[0];
|
||||
const isSupported = (SUPPORTED_LOCALES as unknown as string[]).includes(
|
||||
desiredLocale,
|
||||
localStorage.getItem("preferred-locale") ??
|
||||
navigator.language.split("-")[0];
|
||||
const isSupported = locales.supported.some(
|
||||
({ locale }) => locale === desiredLocale
|
||||
);
|
||||
const isDefault = desiredLocale === DEFAULT_LOCALE;
|
||||
const isDefault = desiredLocale === locales.default;
|
||||
|
||||
if (!isSupported || isDefault) return undefined;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DEFAULT_LOCALE, STRINGS, type SupportedLocale } from '@blitzkit/i18n';
|
||||
import { STRINGS } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
|
||||
export function getStrings(locale: string = DEFAULT_LOCALE) {
|
||||
if (locale in STRINGS) return STRINGS[locale as SupportedLocale];
|
||||
export function getStrings(locale: string = locales.default) {
|
||||
if (locale in STRINGS) return STRINGS[locale];
|
||||
throw new Error(`Unsupported locale: ${locale}`);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import type { Theme } from '@nivo/core';
|
||||
import { Var } from '../radix/var';
|
||||
|
||||
export const nivoTheme = {
|
||||
background: Var('color-background'),
|
||||
text: {
|
||||
fill: Var('gray-contrast'),
|
||||
fontFamily: 'inherit',
|
||||
},
|
||||
axis: {
|
||||
ticks: {
|
||||
text: {
|
||||
fill: Var('gray-indicator'),
|
||||
},
|
||||
line: {
|
||||
stroke: Var('gray-indicator'),
|
||||
},
|
||||
},
|
||||
},
|
||||
grid: {
|
||||
line: {
|
||||
stroke: Var('gray-indicator'),
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
container: {
|
||||
background: Var('color-overlay'),
|
||||
backdropFilter: 'blur(4rem)',
|
||||
WebkitBackdropFilter: 'blur(4rem)',
|
||||
color: Var('gray-contrast'),
|
||||
borderRadius: Var('radius-2'),
|
||||
},
|
||||
},
|
||||
labels: {
|
||||
text: {
|
||||
fill: Var('gray-1'),
|
||||
},
|
||||
},
|
||||
} satisfies Theme;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type RefObject, useEffect, useRef } from 'react';
|
||||
import { type RefObject, useEffect, useRef } from "react";
|
||||
|
||||
interface UseIntersectionOptions extends IntersectionObserverInit {
|
||||
disabled: boolean;
|
||||
@@ -7,9 +7,9 @@ interface UseIntersectionOptions extends IntersectionObserverInit {
|
||||
export function useIntersection(
|
||||
callback: () => void,
|
||||
ref: RefObject<HTMLElement>,
|
||||
options?: UseIntersectionOptions,
|
||||
options?: UseIntersectionOptions
|
||||
) {
|
||||
const observer = useRef<IntersectionObserver>();
|
||||
const observer = useRef<IntersectionObserver>(null!);
|
||||
|
||||
useEffect(() => {
|
||||
if (options?.disabled || !ref.current) return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DEFAULT_LOCALE, unwrapper } from '@blitzkit/i18n';
|
||||
import { createContext, useContext, type ReactNode } from 'react';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { unwrapper } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
|
||||
const LocaleContext = createContext<{
|
||||
locale: string;
|
||||
@@ -14,7 +15,7 @@ interface LocaleProviderProps extends LocaleAcceptorProps {
|
||||
export function LocaleProvider({ locale, children }: LocaleProviderProps) {
|
||||
return (
|
||||
<LocaleContext.Provider
|
||||
value={{ locale: locale ?? DEFAULT_LOCALE, localeRaw: locale }}
|
||||
value={{ locale: locale ?? locales.default, localeRaw: locale }}
|
||||
>
|
||||
{children}
|
||||
</LocaleContext.Provider>
|
||||
@@ -25,7 +26,7 @@ export function useLocale() {
|
||||
const context = useContext(LocaleContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error('useLocale must be used within a LocaleProvider');
|
||||
throw new Error("useLocale must be used within a LocaleProvider");
|
||||
}
|
||||
|
||||
const strings = getStrings(context.locale);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { type RefObject, useEffect, useRef, useState } from 'react';
|
||||
import { type RefObject, useEffect, useRef, useState } from "react";
|
||||
|
||||
/**
|
||||
* Thanks GuCier!
|
||||
* Thanks GuCire!
|
||||
*
|
||||
* https://stackoverflow.com/a/65008608/12294756
|
||||
*/
|
||||
export function useOnScreen(ref: RefObject<HTMLElement>) {
|
||||
const [isIntersecting, setIntersecting] = useState(false);
|
||||
const observer = useRef<IntersectionObserver>();
|
||||
const observer = useRef<IntersectionObserver>(null!);
|
||||
|
||||
useEffect(() => {
|
||||
observer.current = new IntersectionObserver(([entry]) =>
|
||||
setIntersecting(entry.isIntersecting),
|
||||
setIntersecting(entry.isIntersecting)
|
||||
);
|
||||
}, [ref]);
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { useProgress } from "@react-three/drei";
|
||||
import { useRef } from "react";
|
||||
|
||||
export function useStableProgress() {
|
||||
const { loaded, total } = useProgress();
|
||||
const progress = useRef(0);
|
||||
|
||||
progress.current = Math.max(
|
||||
progress.current,
|
||||
total === 0 ? 0 : (loaded / total) * 100
|
||||
);
|
||||
|
||||
return progress.current;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { type StoreKeys } from '@nanostores/react';
|
||||
import type { Store } from 'nanostores';
|
||||
import { useStoreKey } from './useStoreKey';
|
||||
|
||||
export function useStoreBoolean<Type>(
|
||||
store: Store<Type>,
|
||||
key: StoreKeys<Store<Type>>,
|
||||
) {
|
||||
return Boolean(useStoreKey(store, key));
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { useStore, type StoreKeys } from '@nanostores/react';
|
||||
import type { Store } from 'nanostores';
|
||||
|
||||
export function useStoreKey<Type, Key extends StoreKeys<Store<Type>>>(
|
||||
store: Store<Type>,
|
||||
key: Key,
|
||||
) {
|
||||
const state = useStore(store, { keys: [key] });
|
||||
return state[key];
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
---
|
||||
import '@fontsource/inter';
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { BlitzKitTheme } from '../components/BlitzKitTheme';
|
||||
import { Checks } from '../components/Checks';
|
||||
import Footer from '../components/Footer.astro';
|
||||
import Navbar from '../components/Navbar.astro';
|
||||
import Party3 from '../components/Party3.astro';
|
||||
import './base.css';
|
||||
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
||||
import Servicing from '../components/Servicing.astro';
|
||||
import strings from "@blitzkit/i18n/strings/en.json";
|
||||
import "@fontsource/inter";
|
||||
import { Flex } from "@radix-ui/themes";
|
||||
import Analytics from "../components/Analytics.astro";
|
||||
import { BlitzKitTheme } from "../components/BlitzKitTheme";
|
||||
import { Checks } from "../components/Checks";
|
||||
import Footer from "../components/Footer.astro";
|
||||
import LocaleRedirector from "../components/LocaleRedirector.astro";
|
||||
import Meta from "../components/Meta.astro";
|
||||
import Navbar from "../components/Navbar.astro";
|
||||
import PWA from "../components/PWA.astro";
|
||||
import PWAPrompter from "../components/PWAPrompter.astro";
|
||||
import Servicing from "../components/Servicing.astro";
|
||||
import "./base.css";
|
||||
|
||||
export interface Props {
|
||||
noFooter?: boolean;
|
||||
@@ -18,50 +22,29 @@ export interface Props {
|
||||
|
||||
const servicing = import.meta.env.SERVICING;
|
||||
const { noFooter, noNavbar, integrated } = Astro.props;
|
||||
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||
const locale = Astro.params.locale;
|
||||
---
|
||||
|
||||
<html lang={locale}>
|
||||
<head>
|
||||
<meta property="og:site_name" content="BlitzKit" />
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
<meta property="og:site_name" content={strings.common.name} />
|
||||
|
||||
<Party3 />
|
||||
|
||||
<script>
|
||||
import { SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
||||
import { getBestLocale } from '../core/i18n/getBestLocale';
|
||||
const isAPI = window.location.pathname.startsWith('/api');
|
||||
const isI18nPath = SUPPORTED_LOCALES.some((locale) =>
|
||||
window.location.pathname.startsWith(`/${locale}`),
|
||||
);
|
||||
const bestLocale = getBestLocale();
|
||||
const currentPathLocale = SUPPORTED_LOCALES.find((locale) =>
|
||||
window.location.pathname.startsWith(`/${locale}`),
|
||||
);
|
||||
|
||||
if (
|
||||
!isAPI && // not an api, duh!
|
||||
localStorage.getItem('preferred-locale') !== null && // no preference, so probably google's crawler
|
||||
bestLocale !== currentPathLocale // we need to redirect
|
||||
) {
|
||||
window.location.pathname = isI18nPath
|
||||
? window.location.pathname.replace(
|
||||
`/${currentPathLocale}`,
|
||||
bestLocale === undefined ? '' : `/${bestLocale}`,
|
||||
)
|
||||
: `/${bestLocale}${window.location.pathname}`;
|
||||
}
|
||||
</script>
|
||||
<PWA />
|
||||
<Meta />
|
||||
<Analytics />
|
||||
<LocaleRedirector />
|
||||
|
||||
<slot name="head" />
|
||||
</head>
|
||||
|
||||
<body class={noNavbar ? 'no-navbar' : ''}>
|
||||
<body class={noNavbar ? "no-navbar" : ""}>
|
||||
<BlitzKitTheme>
|
||||
{
|
||||
Astro.routePattern !== "/[...locale]" && (
|
||||
<PWAPrompter {locale} floating />
|
||||
)
|
||||
}
|
||||
|
||||
<Flex direction="column" minHeight="100vh">
|
||||
<Navbar {integrated} />
|
||||
|
||||
|
||||