mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
fix: self core imports
This commit is contained in:
1 parent
1790443698
commit
03a51c47bb
31 files changed
+143
-136
No files matched your search
@@ -57,22 +57,24 @@
|
|||||||
"packages/core": {
|
"packages/core": {
|
||||||
"name": "@blitzkit/core",
|
"name": "@blitzkit/core",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@blitzkit/i18n": "workspace:*",
|
||||||
|
"@bufbuild/protobuf": "^2.9.0",
|
||||||
"@octokit/plugin-throttling": "^11.0.1",
|
"@octokit/plugin-throttling": "^11.0.1",
|
||||||
"@octokit/rest": "^22.0.0",
|
"@octokit/rest": "^22.0.0",
|
||||||
"@prisma/client": "^6.16.2",
|
"@prisma/client": "^6.16.2",
|
||||||
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/lz4js": "^0.2.1",
|
||||||
|
"@types/three": "^0.180.0",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"crc": "^4.3.2",
|
"crc": "^4.3.2",
|
||||||
"dotenv": "^17.2.2",
|
"dotenv": "^17.2.2",
|
||||||
"lz4js": "^0.2.0",
|
"lz4js": "^0.2.0",
|
||||||
"pickleparser": "^0.2.1",
|
"pickleparser": "^0.2.1",
|
||||||
"protobufjs": "^7.5.4",
|
"protobufjs": "^7.5.4",
|
||||||
|
"three": "^0.180.0",
|
||||||
"ts-proto": "^2.7.7",
|
"ts-proto": "^2.7.7",
|
||||||
"yaml": "^2.8.1",
|
"yaml": "^2.8.1",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
|
||||||
"@types/adm-zip": "^0.5.7",
|
|
||||||
"@types/lz4js": "^0.2.1",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"packages/i18n": {
|
"packages/i18n": {
|
||||||
"name": "@blitzkit/i18n",
|
"name": "@blitzkit/i18n",
|
||||||
@@ -2741,8 +2743,6 @@
|
|||||||
|
|
||||||
"@blitzkit/app/typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw=="],
|
"@blitzkit/app/typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw=="],
|
||||||
|
|
||||||
"@blitzkit/core/@prisma/client": ["@prisma/[email protected]", "", { "peerDependencies": { "prisma": "*", "typescript": ">=5.1.0" }, "optionalPeers": ["prisma", "typescript"] }, "sha512-E00PxBcalMfYO/TWnXobBVUai6eW/g5OsifWQsQDzJYm7yaY+IRLo7ZLsaefi0QkTpxfuhFcQ/w180i6kX3iJw=="],
|
|
||||||
|
|
||||||
"@discordjs/rest/@discordjs/collection": ["@discordjs/[email protected]", "", {}, "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="],
|
"@discordjs/rest/@discordjs/collection": ["@discordjs/[email protected]", "", {}, "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="],
|
||||||
|
|
||||||
"@discordjs/rest/undici": ["[email protected]", "", {}, "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw=="],
|
"@discordjs/rest/undici": ["[email protected]", "", {}, "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw=="],
|
||||||
|
|||||||
@@ -4,20 +4,22 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@blitzkit/i18n": "workspace:*",
|
||||||
|
"@bufbuild/protobuf": "^2.9.0",
|
||||||
"@octokit/plugin-throttling": "^11.0.1",
|
"@octokit/plugin-throttling": "^11.0.1",
|
||||||
"@octokit/rest": "^22.0.0",
|
"@octokit/rest": "^22.0.0",
|
||||||
"@prisma/client": "^6.16.2",
|
"@prisma/client": "^6.16.2",
|
||||||
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/lz4js": "^0.2.1",
|
||||||
|
"@types/three": "^0.180.0",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"crc": "^4.3.2",
|
"crc": "^4.3.2",
|
||||||
"dotenv": "^17.2.2",
|
"dotenv": "^17.2.2",
|
||||||
"lz4js": "^0.2.0",
|
"lz4js": "^0.2.0",
|
||||||
"pickleparser": "^0.2.1",
|
"pickleparser": "^0.2.1",
|
||||||
"protobufjs": "^7.5.4",
|
"protobufjs": "^7.5.4",
|
||||||
|
"three": "^0.180.0",
|
||||||
"ts-proto": "^2.7.7",
|
"ts-proto": "^2.7.7",
|
||||||
"yaml": "^2.8.1"
|
"yaml": "^2.8.1"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/adm-zip": "^0.5.7",
|
|
||||||
"@types/lz4js": "^0.2.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { type ShellDefinition, ShellType } from '@blitzkit/core';
|
import { ShellDefinition, ShellType } from "../protos";
|
||||||
|
|
||||||
export function canSplash(type: ShellDefinition['type']): type is ShellType.HE {
|
export function canSplash(type: ShellDefinition["type"]): type is ShellType.HE {
|
||||||
return type === ShellType.HE;
|
return type === ShellType.HE;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BlitzStats, calculateWN8 } from '@blitzkit/core';
|
import { BlitzStats, calculateWN8 } from "../statistics";
|
||||||
|
|
||||||
export type Stat = keyof ReturnType<typeof generateStats>;
|
export type Stat = keyof ReturnType<typeof generateStats>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
import { fetchBlitz } from "./fetchBlitz";
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from "./normalizeIds";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
|
||||||
interface IndividualAccountAchievements {
|
interface IndividualAccountAchievements {
|
||||||
achievements: {
|
achievements: {
|
||||||
@@ -22,11 +23,11 @@ export async function getAccountAchievements<
|
|||||||
>(region: Region, ids: Ids) {
|
>(region: Region, ids: Ids) {
|
||||||
const object = await fetchBlitz<AccountAchievements>(
|
const object = await fetchBlitz<AccountAchievements>(
|
||||||
region,
|
region,
|
||||||
'account/achievements',
|
"account/achievements",
|
||||||
{ account_id: normalizeIds(ids) },
|
{ account_id: normalizeIds(ids) }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (typeof ids === 'number') {
|
if (typeof ids === "number") {
|
||||||
return object[ids as number] as ReturnType;
|
return object[ids as number] as ReturnType;
|
||||||
} else {
|
} else {
|
||||||
return ids.map((id) => object[id]) as ReturnType;
|
return ids.map((id) => object[id]) as ReturnType;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {
|
import { BlitzStats } from "../statistics";
|
||||||
BlitzStats,
|
import { FetchBlitzParams, fetchBlitz } from "./fetchBlitz";
|
||||||
FetchBlitzParams,
|
import { normalizeIds } from "./normalizeIds";
|
||||||
Region,
|
import { Region } from "./regions";
|
||||||
fetchBlitz,
|
|
||||||
} from '@blitzkit/core';
|
|
||||||
import { normalizeIds } from './normalizeIds';
|
|
||||||
|
|
||||||
export interface SupplementaryStats {
|
export interface SupplementaryStats {
|
||||||
WN8?: number;
|
WN8?: number;
|
||||||
@@ -83,15 +80,15 @@ export async function getAccountInfo<
|
|||||||
region: Region,
|
region: Region,
|
||||||
ids: Ids,
|
ids: Ids,
|
||||||
extra: string[] = [],
|
extra: string[] = [],
|
||||||
params: FetchBlitzParams = {},
|
params: FetchBlitzParams = {}
|
||||||
) {
|
) {
|
||||||
const object = await fetchBlitz<AccountInfo>(region, 'account/info', {
|
const object = await fetchBlitz<AccountInfo>(region, "account/info", {
|
||||||
account_id: normalizeIds(ids),
|
account_id: normalizeIds(ids),
|
||||||
extra: extra.length === 0 ? undefined : extra.join(','),
|
extra: extra.length === 0 ? undefined : extra.join(","),
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof ids === 'number') {
|
if (typeof ids === "number") {
|
||||||
return object[ids as number] as ReturnType;
|
return object[ids as number] as ReturnType;
|
||||||
} else {
|
} else {
|
||||||
return ids.map((id) => object[id]) as ReturnType;
|
return ids.map((id) => object[id]) as ReturnType;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
import { fetchBlitz } from "./fetchBlitz";
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from "./normalizeIds";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
|
||||||
type IndividualClanAccountInfo = {
|
type IndividualClanAccountInfo = {
|
||||||
account_id: number;
|
account_id: number;
|
||||||
@@ -30,14 +31,14 @@ export async function getClanAccountInfo<
|
|||||||
>(region: Region, ids: Ids, extra: string[] = []) {
|
>(region: Region, ids: Ids, extra: string[] = []) {
|
||||||
const object = await fetchBlitz<ClanAccountInfo>(
|
const object = await fetchBlitz<ClanAccountInfo>(
|
||||||
region,
|
region,
|
||||||
'clans/accountinfo',
|
"clans/accountinfo",
|
||||||
{
|
{
|
||||||
account_id: normalizeIds(ids),
|
account_id: normalizeIds(ids),
|
||||||
extra: extra.length === 0 ? undefined : extra.join(','),
|
extra: extra.length === 0 ? undefined : extra.join(","),
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (typeof ids === 'number') {
|
if (typeof ids === "number") {
|
||||||
return object[ids as number] as ReturnType;
|
return object[ids as number] as ReturnType;
|
||||||
} else {
|
} else {
|
||||||
return ids.map((id) => object[id]) as ReturnType;
|
return ids.map((id) => object[id]) as ReturnType;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
import { fetchBlitz } from "./fetchBlitz";
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from "./normalizeIds";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
|
||||||
interface IndividualClanInfo {
|
interface IndividualClanInfo {
|
||||||
recruiting_options: {
|
recruiting_options: {
|
||||||
@@ -38,11 +39,11 @@ export async function getClanInfo<
|
|||||||
Ids extends number | number[],
|
Ids extends number | number[],
|
||||||
ReturnType = Ids extends number ? IndividualClanInfo : IndividualClanInfo[],
|
ReturnType = Ids extends number ? IndividualClanInfo : IndividualClanInfo[],
|
||||||
>(region: Region, ids: Ids) {
|
>(region: Region, ids: Ids) {
|
||||||
const object = await fetchBlitz<ClanInfo>(region, 'clans/info', {
|
const object = await fetchBlitz<ClanInfo>(region, "clans/info", {
|
||||||
clan_id: normalizeIds(ids),
|
clan_id: normalizeIds(ids),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof ids === 'number') {
|
if (typeof ids === "number") {
|
||||||
return object[ids as number] as ReturnType;
|
return object[ids as number] as ReturnType;
|
||||||
} else {
|
} else {
|
||||||
return ids.map((id) => object[id]) as ReturnType;
|
return ids.map((id) => object[id]) as ReturnType;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { LEAGUES } from '@blitzkit/core';
|
import { LEAGUES } from "./rating";
|
||||||
|
|
||||||
export function getLeagueFromScore(score: number) {
|
export function getLeagueFromScore(score: number) {
|
||||||
return LEAGUES.find(({ minScore }) => score >= minScore)!;
|
return LEAGUES.find(({ minScore }) => score >= minScore)!;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { RatingLeague, RatingReward, Region } from '@blitzkit/core';
|
import { context } from "../blitzkit/context";
|
||||||
import { context } from '../blitzkit/context';
|
import { patientFetch } from "../blitzkit/patientFetch";
|
||||||
import { patientFetch } from '../blitzkit/patientFetch';
|
import { RatingLeague, RatingReward } from "./rating";
|
||||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
import { Region } from "./regions";
|
||||||
|
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||||
|
|
||||||
export type RatingInfo =
|
export type RatingInfo =
|
||||||
| {
|
| {
|
||||||
@@ -26,12 +27,12 @@ export async function getRatingInfo(region: Region) {
|
|||||||
if (cache[region]) return cache[region]!;
|
if (cache[region]) return cache[region]!;
|
||||||
|
|
||||||
const response = await patientFetch(
|
const response = await patientFetch(
|
||||||
context === 'website'
|
context === "website"
|
||||||
? `/api/${region}/rating/current/info`
|
? `/api/${region}/rating/current/info`
|
||||||
: `https://${regionToRegionSubdomain(
|
: `https://${regionToRegionSubdomain(
|
||||||
region,
|
region
|
||||||
)}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
)}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||||
undefined,
|
undefined
|
||||||
);
|
);
|
||||||
const data = (await response.json()) as RatingInfo;
|
const data = (await response.json()) as RatingInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
import { LeagueTop, RatingPlayer, Region } from '@blitzkit/core';
|
import { context } from "../blitzkit/context";
|
||||||
import { context } from '../blitzkit/context';
|
import { patientFetch } from "../blitzkit/patientFetch";
|
||||||
import { patientFetch } from '../blitzkit/patientFetch';
|
import { RatingPlayer } from "../statistics";
|
||||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
import { LeagueTop } from "./rating";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||||
|
|
||||||
export async function getRatingLeague(
|
export async function getRatingLeague(
|
||||||
region: Region,
|
region: Region,
|
||||||
league: number,
|
league: number,
|
||||||
usePatientFetcher = false,
|
usePatientFetcher = false
|
||||||
) {
|
) {
|
||||||
const fetcher = (url: string) =>
|
const fetcher = (url: string) =>
|
||||||
usePatientFetcher
|
usePatientFetcher
|
||||||
? patientFetch(url, undefined, { cache: 'no-store' })
|
? patientFetch(url, undefined, { cache: "no-store" })
|
||||||
: fetch(url, { cache: 'no-store' });
|
: fetch(url, { cache: "no-store" });
|
||||||
const response = await fetcher(
|
const response = await fetcher(
|
||||||
context === 'website'
|
context === "website"
|
||||||
? `/api/${region}/rating/current/league/${league}`
|
? `/api/${region}/rating/current/league/${league}`
|
||||||
: `https://${regionToRegionSubdomain(
|
: `https://${regionToRegionSubdomain(
|
||||||
region,
|
region
|
||||||
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`
|
||||||
);
|
);
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
return context === 'website'
|
return context === "website"
|
||||||
? (json as RatingPlayer[])
|
? (json as RatingPlayer[])
|
||||||
: (json as LeagueTop).result;
|
: (json as LeagueTop).result;
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
import { RatingNeighbors, Region } from '@blitzkit/core';
|
import { patientFetch } from "../blitzkit/patientFetch";
|
||||||
import { patientFetch } from '../blitzkit/patientFetch';
|
import { withCORSProxy } from "../blitzkit/withCORSProxy";
|
||||||
import { withCORSProxy } from '../blitzkit/withCORSProxy';
|
import { RatingNeighbors } from "./rating";
|
||||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
import { Region } from "./regions";
|
||||||
|
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||||
|
|
||||||
export async function getRatingNeighbors(
|
export async function getRatingNeighbors(
|
||||||
region: Region,
|
region: Region,
|
||||||
id: number,
|
id: number,
|
||||||
count: number,
|
count: number,
|
||||||
usePatientFetcher = false,
|
usePatientFetcher = false
|
||||||
) {
|
) {
|
||||||
const fetcher = (url: string) =>
|
const fetcher = (url: string) =>
|
||||||
usePatientFetcher
|
usePatientFetcher
|
||||||
? patientFetch(url, undefined, { cache: 'no-store' })
|
? patientFetch(url, undefined, { cache: "no-store" })
|
||||||
: fetch(url, { cache: 'no-store' });
|
: fetch(url, { cache: "no-store" });
|
||||||
const response = await fetcher(
|
const response = await fetcher(
|
||||||
withCORSProxy(
|
withCORSProxy(
|
||||||
`https://${regionToRegionSubdomain(
|
`https://${regionToRegionSubdomain(
|
||||||
region,
|
region
|
||||||
)}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${count}`,
|
)}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${count}`
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
const json = (await response.json()) as RatingNeighbors;
|
const json = (await response.json()) as RatingNeighbors;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
import {
|
import { TanksStats } from "../types";
|
||||||
fetchBlitz,
|
import { FetchBlitzParams, fetchBlitz } from "./fetchBlitz";
|
||||||
FetchBlitzParams,
|
import { Region } from "./regions";
|
||||||
Region,
|
|
||||||
TanksStats,
|
|
||||||
} from '@blitzkit/core';
|
|
||||||
|
|
||||||
export async function getTankStats(
|
export async function getTankStats(
|
||||||
region: Region,
|
region: Region,
|
||||||
id: number,
|
id: number,
|
||||||
params?: FetchBlitzParams,
|
params?: FetchBlitzParams
|
||||||
) {
|
) {
|
||||||
const tankStats = await fetchBlitz<TanksStats>(region, 'tanks/stats', {
|
const tankStats = await fetchBlitz<TanksStats>(region, "tanks/stats", {
|
||||||
account_id: id,
|
account_id: id,
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getRatingInfo } from '@blitzkit/core';
|
import { getRatingInfo } from "./getRatingInfo";
|
||||||
|
|
||||||
export async function isOnGoingRatingSeason() {
|
export async function isOnGoingRatingSeason() {
|
||||||
const ratingInfo = await getRatingInfo('com');
|
const ratingInfo = await getRatingInfo("com");
|
||||||
return ratingInfo.detail === undefined;
|
return ratingInfo.detail === undefined;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Region, assertSecret, idToRegion } from '@blitzkit/core';
|
import { assertSecret } from "../blitzkit";
|
||||||
|
import { idToRegion } from "./idToRegion";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
|
||||||
export async function isValidBlitzId(id: number, token?: string) {
|
export async function isValidBlitzId(id: number, token?: string) {
|
||||||
let region: Region;
|
let region: Region;
|
||||||
@@ -11,20 +13,20 @@ export async function isValidBlitzId(id: number, token?: string) {
|
|||||||
|
|
||||||
const json = await fetch(
|
const json = await fetch(
|
||||||
`https://api.wotblitz.${region}/wotb/account/info/?account_id=${id}&application_id=${assertSecret(
|
`https://api.wotblitz.${region}/wotb/account/info/?account_id=${id}&application_id=${assertSecret(
|
||||||
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID,
|
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID
|
||||||
)}${
|
)}${
|
||||||
token === undefined ? '' : `&access_token=${token}`
|
token === undefined ? "" : `&access_token=${token}`
|
||||||
}&fields=account_id%2C-account_id`,
|
}&fields=account_id%2C-account_id`
|
||||||
).then(
|
).then(
|
||||||
(response) =>
|
(response) =>
|
||||||
response.json() as Promise<
|
response.json() as Promise<
|
||||||
| {
|
| {
|
||||||
status: 'ok';
|
status: "ok";
|
||||||
data: Record<number, {} | null>;
|
data: Record<number, {} | null>;
|
||||||
}
|
}
|
||||||
| { status: 'error' }
|
| { status: "error" }
|
||||||
>,
|
>
|
||||||
);
|
);
|
||||||
|
|
||||||
return json.status === 'ok' && json.data[id] !== null;
|
return json.status === "ok" && json.data[id] !== null;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Region, RegionSubdomain } from '@blitzkit/core';
|
import { Region, RegionSubdomain } from "./regions";
|
||||||
|
|
||||||
export function regionSubdomainToRegion(regionDomain: RegionSubdomain): Region {
|
export function regionSubdomainToRegion(regionDomain: RegionSubdomain): Region {
|
||||||
return regionDomain === 'na' ? 'com' : regionDomain;
|
return regionDomain === "na" ? "com" : regionDomain;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Region, RegionSubdomain } from '@blitzkit/core';
|
import { Region, RegionSubdomain } from "./regions";
|
||||||
|
|
||||||
export function regionToRegionSubdomain(regionDomain: Region): RegionSubdomain {
|
export function regionToRegionSubdomain(regionDomain: Region): RegionSubdomain {
|
||||||
return regionDomain === 'com' ? 'na' : regionDomain;
|
return regionDomain === "com" ? "na" : regionDomain;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
import { ClanList } from "./clans";
|
||||||
import { ClanList } from './clans';
|
import { fetchBlitz } from "./fetchBlitz";
|
||||||
|
import { Region } from "./regions";
|
||||||
|
|
||||||
export async function searchClansAcrossRegions(search: string, limit = 25) {
|
export async function searchClansAcrossRegions(search: string, limit = 25) {
|
||||||
const trimmed = search.trim();
|
const trimmed = search.trim();
|
||||||
@@ -10,38 +11,38 @@ export async function searchClansAcrossRegions(search: string, limit = 25) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fetchBlitz<ClanList>('com', 'clans/list', {
|
fetchBlitz<ClanList>("com", "clans/list", {
|
||||||
search,
|
search,
|
||||||
limit: normalizedLimit,
|
limit: normalizedLimit,
|
||||||
}).then((value) =>
|
}).then((value) =>
|
||||||
value
|
value
|
||||||
.map((account) => ({
|
.map((account) => ({
|
||||||
...account,
|
...account,
|
||||||
region: 'com' as Region,
|
region: "com" as Region,
|
||||||
}))
|
}))
|
||||||
.splice(0, normalizedLimit),
|
.splice(0, normalizedLimit)
|
||||||
),
|
),
|
||||||
fetchBlitz<ClanList>('eu', 'clans/list', {
|
fetchBlitz<ClanList>("eu", "clans/list", {
|
||||||
search,
|
search,
|
||||||
limit: normalizedLimit,
|
limit: normalizedLimit,
|
||||||
}).then((value) =>
|
}).then((value) =>
|
||||||
value
|
value
|
||||||
.map((account) => ({
|
.map((account) => ({
|
||||||
...account,
|
...account,
|
||||||
region: 'eu' as Region,
|
region: "eu" as Region,
|
||||||
}))
|
}))
|
||||||
.splice(0, normalizedLimit),
|
.splice(0, normalizedLimit)
|
||||||
),
|
),
|
||||||
fetchBlitz<ClanList>('asia', 'clans/list', {
|
fetchBlitz<ClanList>("asia", "clans/list", {
|
||||||
search,
|
search,
|
||||||
limit: normalizedLimit,
|
limit: normalizedLimit,
|
||||||
}).then((value) =>
|
}).then((value) =>
|
||||||
value
|
value
|
||||||
.map((account) => ({
|
.map((account) => ({
|
||||||
...account,
|
...account,
|
||||||
region: 'asia' as Region,
|
region: "asia" as Region,
|
||||||
}))
|
}))
|
||||||
.splice(0, normalizedLimit),
|
.splice(0, normalizedLimit)
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '@blitzkit/core';
|
import { context } from "../blitzkit/context";
|
||||||
import { context } from '../blitzkit/context';
|
import { Region } from "./regions";
|
||||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||||
|
|
||||||
type CurrentRatingPlayerSearch = Record<
|
type CurrentRatingPlayerSearch = Record<
|
||||||
number,
|
number,
|
||||||
@@ -27,12 +27,12 @@ type CurrentRatingPlayerSearch = Record<
|
|||||||
export async function searchCurrentRatingPlayers(region: Region, name: string) {
|
export async function searchCurrentRatingPlayers(region: Region, name: string) {
|
||||||
const encodedSearch = encodeURIComponent(name);
|
const encodedSearch = encodeURIComponent(name);
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
context === 'website'
|
context === "website"
|
||||||
? `/api/${region}/rating/current/search/${encodedSearch}`
|
? `/api/${region}/rating/current/search/${encodedSearch}`
|
||||||
: `https://${regionToRegionSubdomain(
|
: `https://${regionToRegionSubdomain(
|
||||||
region,
|
region
|
||||||
)}.wotblitz.com/en/api/rating-leaderboards/search/?prefix=${encodedSearch}`,
|
)}.wotblitz.com/en/api/rating-leaderboards/search/?prefix=${encodedSearch}`,
|
||||||
{ cache: 'no-store' },
|
{ cache: "no-store" }
|
||||||
);
|
);
|
||||||
const accountList = (await response.json()) as CurrentRatingPlayerSearch;
|
const accountList = (await response.json()) as CurrentRatingPlayerSearch;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
import { fetchBlitz } from '../fetchBlitz';
|
||||||
|
import { Region } from '../regions';
|
||||||
import { usernamePattern } from './constants';
|
import { usernamePattern } from './constants';
|
||||||
|
|
||||||
export interface AccountListItem {
|
export interface AccountListItem {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { NATION_IDS } from "@blitzkit/core";
|
import { NATION_IDS } from "./nations";
|
||||||
|
|
||||||
export function toUniqueId(nation: string, id: number) {
|
export function toUniqueId(nation: string, id: number) {
|
||||||
return (id << 8) + (NATION_IDS[nation] << 4) + 1;
|
return (id << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
import {
|
import { GunDefinition, ProvisionDefinitions, TankDefinition } from "../protos";
|
||||||
GunDefinition,
|
import { checkConsumableProvisionInclusivity } from "./checkConsumableProvisionInclusivity";
|
||||||
ProvisionDefinitions,
|
|
||||||
TankDefinition,
|
|
||||||
} from '@blitzkit/core';
|
|
||||||
import { checkConsumableProvisionInclusivity } from './checkConsumableProvisionInclusivity';
|
|
||||||
|
|
||||||
export function availableProvisions(
|
export function availableProvisions(
|
||||||
tank: TankDefinition,
|
tank: TankDefinition,
|
||||||
gun: GunDefinition,
|
gun: GunDefinition,
|
||||||
provisionDefinitions: ProvisionDefinitions,
|
provisionDefinitions: ProvisionDefinitions
|
||||||
) {
|
) {
|
||||||
return Object.values(provisionDefinitions.provisions).filter((provision) =>
|
return Object.values(provisionDefinitions.provisions).filter((provision) =>
|
||||||
checkConsumableProvisionInclusivity(provision, tank, gun),
|
checkConsumableProvisionInclusivity(provision, tank, gun)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { SkillDefinitions } from '@blitzkit/core';
|
import { SkillDefinitions } from "..";
|
||||||
import { permanentSkills } from '../blitz/permanentSkills';
|
import { permanentSkills } from "../blitz/permanentSkills";
|
||||||
|
|
||||||
export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
||||||
const skills: Record<string, number> = {};
|
const skills: Record<string, number> = {};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { assertSecret, getRatingInfo } from '@blitzkit/core';
|
import { getRatingInfo } from "../blitz/getRatingInfo";
|
||||||
|
import { assertSecret } from "./assertSecret";
|
||||||
|
|
||||||
interface GitHubTrees {
|
interface GitHubTrees {
|
||||||
tree: { path: string; url: string }[];
|
tree: { path: string; url: string }[];
|
||||||
@@ -11,21 +12,21 @@ export async function getArchivedLatestSeasonNumber() {
|
|||||||
return cachedLatestArchivedSeasonNumber;
|
return cachedLatestArchivedSeasonNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ratingInfo = await getRatingInfo('com');
|
const ratingInfo = await getRatingInfo("com");
|
||||||
|
|
||||||
if (ratingInfo.detail) {
|
if (ratingInfo.detail) {
|
||||||
const regionsURL = (
|
const regionsURL = (
|
||||||
(await fetch(
|
(await fetch(
|
||||||
`https://api.github.com/repos/tresabhi/${assertSecret(
|
`https://api.github.com/repos/tresabhi/${assertSecret(
|
||||||
import.meta.env.PUBLIC_ASSET_REPO,
|
import.meta.env.PUBLIC_ASSET_REPO
|
||||||
)}/git/trees/main`,
|
)}/git/trees/main`
|
||||||
).then((response) => response.json())) as GitHubTrees
|
).then((response) => response.json())) as GitHubTrees
|
||||||
).tree.find(({ path }) => path === 'regions')!.url;
|
).tree.find(({ path }) => path === "regions")!.url;
|
||||||
const comURL = (
|
const comURL = (
|
||||||
(await fetch(regionsURL).then((response) =>
|
(await fetch(regionsURL).then((response) =>
|
||||||
response.json(),
|
response.json()
|
||||||
)) as GitHubTrees
|
)) as GitHubTrees
|
||||||
).tree.find(({ path }) => path === 'com')!.url;
|
).tree.find(({ path }) => path === "com")!.url;
|
||||||
const ratingURL = (
|
const ratingURL = (
|
||||||
(await fetch(comURL).then((response) => response.json())) as {
|
(await fetch(comURL).then((response) => response.json())) as {
|
||||||
tree: [{ url: string }];
|
tree: [{ url: string }];
|
||||||
@@ -36,7 +37,7 @@ export async function getArchivedLatestSeasonNumber() {
|
|||||||
(await fetch(ratingURL).then((response) => response.json())) as {
|
(await fetch(ratingURL).then((response) => response.json())) as {
|
||||||
tree: { path: string }[];
|
tree: { path: string }[];
|
||||||
}
|
}
|
||||||
).tree.map(({ path }) => Number(path)),
|
).tree.map(({ path }) => Number(path))
|
||||||
);
|
);
|
||||||
|
|
||||||
cachedLatestArchivedSeasonNumber = latestSeason;
|
cachedLatestArchivedSeasonNumber = latestSeason;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { asset, RatingLeaderboard, Region } from '@blitzkit/core';
|
import { Region } from "../blitz/regions";
|
||||||
|
import { RatingLeaderboard } from "../protos";
|
||||||
|
import { asset } from "./asset";
|
||||||
|
|
||||||
const cache: Record<Region, Record<number, RatingLeaderboard>> = {
|
const cache: Record<Region, Record<number, RatingLeaderboard>> = {
|
||||||
asia: {},
|
asia: {},
|
||||||
@@ -8,7 +10,7 @@ const cache: Record<Region, Record<number, RatingLeaderboard>> = {
|
|||||||
|
|
||||||
export async function getArchivedRatingLeaderboard(
|
export async function getArchivedRatingLeaderboard(
|
||||||
region: Region,
|
region: Region,
|
||||||
season: number,
|
season: number
|
||||||
) {
|
) {
|
||||||
if (!cache[region][season]) {
|
if (!cache[region][season]) {
|
||||||
const info = await fetch(asset(`regions/${region}/rating/${season}.pb`))
|
const info = await fetch(asset(`regions/${region}/rating/${season}.pb`))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Region } from '@blitzkit/core';
|
import { Region } from "../blitz/regions";
|
||||||
|
|
||||||
const TIME_ZONE_MAPPINGS: Record<Region, number> = {
|
const TIME_ZONE_MAPPINGS: Record<Region, number> = {
|
||||||
com: -5, // Central North American Time
|
com: -5, // Central North American Time
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ShellDefinition, ShellType } from '@blitzkit/core';
|
import { ShellDefinition, ShellType } from "../protos";
|
||||||
|
|
||||||
export function isExplosive(
|
export function isExplosive(
|
||||||
type: ShellDefinition['type'],
|
type: ShellDefinition["type"]
|
||||||
): type is ShellType.HEAT | ShellType.HE {
|
): type is ShellType.HEAT | ShellType.HE {
|
||||||
return type === ShellType.HEAT || type === ShellType.HE;
|
return type === ShellType.HEAT || type === ShellType.HE;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { BoundingBox, Vector3 } from '@blitzkit/core';
|
import { Vector3 } from "three";
|
||||||
|
import { BoundingBox } from "../protos";
|
||||||
|
|
||||||
export function normalizeBoundingBox(boundingBox: BoundingBox) {
|
export function normalizeBoundingBox(boundingBox: BoundingBox) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BKNI_COLORS, BkniPercentile, getBkniPercentile } from '@blitzkit/core';
|
import { BKNI_COLORS, BkniPercentile, getBkniPercentile } from "../statistics";
|
||||||
|
|
||||||
export function parseBkni(bkni: number) {
|
export function parseBkni(bkni: number) {
|
||||||
const bkniFraction = (bkni + 1) / 2;
|
const bkniFraction = (bkni + 1) / 2;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { asset } from "@blitzkit/core";
|
import { asset } from "./asset";
|
||||||
|
|
||||||
export const BLITZKIT_TANK_ICON_SIZE = { width: 40 * 16, height: 30 * 16 };
|
export const BLITZKIT_TANK_ICON_SIZE = { width: 40 * 16, height: 30 * 16 };
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BoundingBox } from '@blitzkit/core';
|
import { BoundingBox } from "../protos";
|
||||||
|
|
||||||
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in new issue
Block a user