mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-25 23:23:21 +01:00
Compare commits
4
Commits
4e170f2917
...
383d3a36ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
383d3a36ef | ||
|
|
6a958da390 | ||
|
|
ef154f99d5 | ||
|
|
4a20102de3 |
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ depots
|
|||||||
public/sitemap*
|
public/sitemap*
|
||||||
/firebase.json
|
/firebase.json
|
||||||
target
|
target
|
||||||
# packages/core/src/protos/*.ts
|
packages/website-ue/src/protos/*.ts
|
||||||
/.vercel
|
/.vercel
|
||||||
.astro
|
.astro
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
Vendored
+1
@@ -187,6 +187,7 @@
|
|||||||
"searchtanks",
|
"searchtanks",
|
||||||
"SHAREDEXP",
|
"SHAREDEXP",
|
||||||
"SKLLD",
|
"SKLLD",
|
||||||
|
"sluggify",
|
||||||
"smoothstep",
|
"smoothstep",
|
||||||
"Smri",
|
"Smri",
|
||||||
"Specularity",
|
"Specularity",
|
||||||
|
|||||||
@@ -182,6 +182,7 @@
|
|||||||
"@astrojs/node": "^9.4.4",
|
"@astrojs/node": "^9.4.4",
|
||||||
"@astrojs/react": "^4.4.0",
|
"@astrojs/react": "^4.4.0",
|
||||||
"@astrolib/seo": "^1.0.0-beta.8",
|
"@astrolib/seo": "^1.0.0-beta.8",
|
||||||
|
"@blitzkit/closed": "workspace:*",
|
||||||
"@blitzkit/core": "workspace:*",
|
"@blitzkit/core": "workspace:*",
|
||||||
"@blitzkit/i18n": "workspace:*",
|
"@blitzkit/i18n": "workspace:*",
|
||||||
"@radix-ui/colors": "^3.0.0",
|
"@radix-ui/colors": "^3.0.0",
|
||||||
@@ -208,6 +209,7 @@
|
|||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"varuna": "workspace:*",
|
"varuna": "workspace:*",
|
||||||
"vite": "^7.1.9",
|
"vite": "^7.1.9",
|
||||||
|
"yaml": "^2.8.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
Submodule packages/closed updated: 5b4a85d503...dc17bc32e4.
@@ -1,49 +1,50 @@
|
|||||||
export * from './assertSecret';
|
export * from "./assertSecret";
|
||||||
export * from './asset';
|
export * from "./asset";
|
||||||
export * from './availableProvisions';
|
export * from "./availableProvisions";
|
||||||
export * from './averageDefinitions';
|
export * from "./averageDefinitions";
|
||||||
// export * from './camouflageDefinitions';
|
// export * from './camouflageDefinitions';
|
||||||
// export * from './checkConsumableProvisionInclusivity';
|
// export * from './checkConsumableProvisionInclusivity';
|
||||||
export * from './coefficient';
|
export * from "./coefficient";
|
||||||
export * from './consumableDefinitions';
|
export * from "./consumableDefinitions";
|
||||||
// export * from './context';
|
// export * from './context';
|
||||||
export * from './createDefaultSkills';
|
export * from "./createDefaultSkills";
|
||||||
export * from './degressiveStat';
|
export * from "./degressiveStat";
|
||||||
export * from './discoveredIdDefinitions';
|
export * from "./discoveredIdDefinitions";
|
||||||
export * from './emblemURL';
|
export * from "./emblemURL";
|
||||||
export * from './equipmentDefinitions';
|
export * from "./equipmentDefinitions";
|
||||||
export * from './eventManager';
|
export * from "./eventManager";
|
||||||
export * from './gameDefinitions';
|
export * from "./gameDefinitions";
|
||||||
export * from './getArchivedLatestSeasonNumber';
|
export * from "./getArchivedLatestSeasonNumber";
|
||||||
// export * from './getArchivedRatingInfo';
|
// export * from './getArchivedRatingInfo';
|
||||||
export * from './getArchivedRatingLeaderboard';
|
export * from "./getArchivedRatingLeaderboard";
|
||||||
// export * from './getArchivedRatingMidnightLeaderboard';
|
// export * from './getArchivedRatingMidnightLeaderboard';
|
||||||
export * from './getTimeDaysAgo';
|
export * from "./getTimeDaysAgo";
|
||||||
export * from './isExplosive';
|
export * from "./isExplosive";
|
||||||
export * from './mapDefinitions';
|
export * from "./mapDefinitions";
|
||||||
export * from './modelDefinitions';
|
export * from "./modelDefinitions";
|
||||||
export * from './normalizeBoundingBox';
|
export * from "./normalizeBoundingBox";
|
||||||
// export * from './parseBkni';
|
// export * from './parseBkni';
|
||||||
// export * from './patientFetch';
|
// export * from './patientFetch';
|
||||||
export * from './patientFetchJSON';
|
export * from "./patientFetchJSON";
|
||||||
export * from './progressiveStat';
|
export * from "./progressiveStat";
|
||||||
export * from './provisionDefinitions';
|
export * from "./provisionDefinitions";
|
||||||
export * from './resolveDpm';
|
export * from "./resolveDpm";
|
||||||
export * from './resolvePenetrationCoefficient';
|
export * from "./resolvePenetrationCoefficient";
|
||||||
export * from './reviews';
|
export * from "./reviews";
|
||||||
export * from './skillDefinitions';
|
export * from "./skillDefinitions";
|
||||||
export * from './sum';
|
export * from "./sum";
|
||||||
export * from './tankDefinitions';
|
export * from "./tankDefinitions";
|
||||||
export * from './tankIcon';
|
export * from "./tankIcon";
|
||||||
export * from './tankNames';
|
export * from "./tankNames";
|
||||||
export * from './unionBoundingBox';
|
export * from "./unionBoundingBox";
|
||||||
export * from './uniqueGuns';
|
export * from "./uniqueGuns";
|
||||||
export * from './unwrapBlitzkitResponse';
|
export * from "./unwrapBlitzkitResponse";
|
||||||
export * from './votes';
|
export * from "./votes";
|
||||||
// export * from './withCORSProxy';
|
// export * from './withCORSProxy';
|
||||||
export * from './createDefaultProvisions';
|
export * from "./createDefaultProvisions";
|
||||||
export * from './gallery';
|
export * from "./gallery";
|
||||||
export * from './metaSortTank';
|
export * from "./metaSortTank";
|
||||||
export * from './popularTanks';
|
export * from "./popularTanks";
|
||||||
export * from './romanize';
|
export * from "./romanize";
|
||||||
export * from './youtubers';
|
export * from "./sluggify.ts";
|
||||||
|
export * from "./youtubers";
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { deburr } from "lodash-es";
|
||||||
|
|
||||||
|
const nonAlphanumericRegex = /[^a-z0-9]/g;
|
||||||
|
const multipleDashesRegex = /--+/g;
|
||||||
|
const trailingDashRegex = /-$/g;
|
||||||
|
const leadingDashRegex = /^-/g;
|
||||||
|
|
||||||
|
export function sluggify(value: string) {
|
||||||
|
let slug = deburr(value).toLowerCase();
|
||||||
|
slug = slug.replaceAll(nonAlphanumericRegex, "-");
|
||||||
|
slug = slug.replaceAll(multipleDashesRegex, "-");
|
||||||
|
slug = slug.replaceAll(trailingDashRegex, "");
|
||||||
|
slug = slug.replaceAll(leadingDashRegex, "");
|
||||||
|
|
||||||
|
return slug;
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@ const TS_PROTO_EXECUTABLE_LOCATIONS = [
|
|||||||
|
|
||||||
const roots = [
|
const roots = [
|
||||||
// "../../packages/core/src/protos",
|
// "../../packages/core/src/protos",
|
||||||
"../../packages/closed/protos",
|
// "../../packages/closed/protos",
|
||||||
|
"../../packages/website-ue/src/protos",
|
||||||
];
|
];
|
||||||
|
|
||||||
const exec = promisify(execSync);
|
const exec = promisify(execSync);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"@astrojs/node": "^9.4.4",
|
"@astrojs/node": "^9.4.4",
|
||||||
"@astrojs/react": "^4.4.0",
|
"@astrojs/react": "^4.4.0",
|
||||||
"@astrolib/seo": "^1.0.0-beta.8",
|
"@astrolib/seo": "^1.0.0-beta.8",
|
||||||
|
"@blitzkit/closed": "workspace:*",
|
||||||
"@blitzkit/core": "workspace:*",
|
"@blitzkit/core": "workspace:*",
|
||||||
"@blitzkit/i18n": "workspace:*",
|
"@blitzkit/i18n": "workspace:*",
|
||||||
"@radix-ui/colors": "^3.0.0",
|
"@radix-ui/colors": "^3.0.0",
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
"three-stdlib": "^2.36.0",
|
"three-stdlib": "^2.36.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"varuna": "workspace:*",
|
"varuna": "workspace:*",
|
||||||
"vite": "^7.1.9"
|
"vite": "^7.1.9",
|
||||||
|
"yaml": "^2.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||||
|
import type { Tanks } from "../../protos/tanks";
|
||||||
|
|
||||||
|
export abstract class AbstractAPI {
|
||||||
|
abstract tanks(): Promise<Tanks>;
|
||||||
|
|
||||||
|
abstract strings(
|
||||||
|
locale: string,
|
||||||
|
prefix?: string
|
||||||
|
): Promise<Record<string, string>>;
|
||||||
|
|
||||||
|
abstract tank(id: string): Promise<TankCatalogComponent>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { AbstractAPI } from "./abstract";
|
||||||
|
|
||||||
|
export class ClientAPI extends AbstractAPI {}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { AbstractAPI } from "./abstract";
|
||||||
|
|
||||||
|
let dynamicAPI: AbstractAPI;
|
||||||
|
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
const { ProxyClient } = await import("@blitzkit/closed");
|
||||||
|
const { ServerAPI } = await import("./server");
|
||||||
|
|
||||||
|
const proxyClient = await new ProxyClient(
|
||||||
|
import.meta.env.WOTB_SERVER
|
||||||
|
).handshake();
|
||||||
|
const metadata = await proxyClient.metadata();
|
||||||
|
|
||||||
|
dynamicAPI = new ServerAPI(metadata);
|
||||||
|
} else {
|
||||||
|
const { ClientAPI } = await import("./client");
|
||||||
|
|
||||||
|
dynamicAPI = new ClientAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const api = dynamicAPI;
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import type { MetadataAccessor } from "@blitzkit/closed";
|
||||||
|
import { sluggify } from "@blitzkit/core";
|
||||||
|
import type { RemoteStorageComponent } from "@protos/blitz_static_remote_storage_component";
|
||||||
|
import { parse } from "yaml";
|
||||||
|
import type { TanksEntry } from "../../protos/tanks";
|
||||||
|
import { AbstractAPI } from "./abstract";
|
||||||
|
|
||||||
|
interface LocalizationConfig {
|
||||||
|
namespaces: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ServerAPI extends AbstractAPI {
|
||||||
|
constructor(private metadata: MetadataAccessor) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async strings(locale: string) {
|
||||||
|
const clientConfig = this.metadata.item("ClientConfigsEntity.prod");
|
||||||
|
const localizationResources = clientConfig.LocalizationResources();
|
||||||
|
|
||||||
|
if (!localizationResources.remote_storage) {
|
||||||
|
throw new Error("Localization resources not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
let remoteStorage: RemoteStorageComponent | undefined = undefined;
|
||||||
|
|
||||||
|
for (const candidateId of localizationResources.remote_storage
|
||||||
|
.remote_urls) {
|
||||||
|
const item = this.metadata.item(candidateId);
|
||||||
|
const candidate = item.RemoteStorage();
|
||||||
|
|
||||||
|
if (
|
||||||
|
remoteStorage === undefined ||
|
||||||
|
candidate.download_speed_weight > remoteStorage.download_speed_weight
|
||||||
|
) {
|
||||||
|
remoteStorage = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remoteStorage === undefined) {
|
||||||
|
throw new Error("No suitable production remote storage found");
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = await fetch(
|
||||||
|
`${remoteStorage.url}/${remoteStorage.relative_path}/config.yaml`
|
||||||
|
)
|
||||||
|
.then((response) => response.text())
|
||||||
|
.then((text) => parse(text) as LocalizationConfig);
|
||||||
|
const strings: Record<string, string> = {};
|
||||||
|
|
||||||
|
for (const namespace of config.namespaces) {
|
||||||
|
Object.assign(
|
||||||
|
strings,
|
||||||
|
await fetch(
|
||||||
|
`${remoteStorage.url}/${remoteStorage.relative_path}/${namespace}/${locale}.yaml`
|
||||||
|
)
|
||||||
|
.then((response) => response.text())
|
||||||
|
.then((text) => {
|
||||||
|
const strings: Record<string, string> = {};
|
||||||
|
const parsed = parse(text) as Record<string, string>;
|
||||||
|
|
||||||
|
for (const key in parsed) {
|
||||||
|
strings[key] = parsed[key].replaceAll('\\"', '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
async tanks() {
|
||||||
|
const group = this.metadata.group("TankEntity");
|
||||||
|
const tanks: TanksEntry[] = [];
|
||||||
|
const strings = await this.strings("en");
|
||||||
|
|
||||||
|
for (const item of group) {
|
||||||
|
const tankCatalog = item.TankCatalog();
|
||||||
|
|
||||||
|
if (!tankCatalog.name) continue;
|
||||||
|
|
||||||
|
const name = strings[tankCatalog.name.value];
|
||||||
|
|
||||||
|
if (!name) continue;
|
||||||
|
|
||||||
|
const id = item.name;
|
||||||
|
const slug = sluggify(name);
|
||||||
|
|
||||||
|
tanks.push({ id, slug });
|
||||||
|
}
|
||||||
|
|
||||||
|
return { tanks };
|
||||||
|
}
|
||||||
|
|
||||||
|
async tank(id: string) {
|
||||||
|
const item = this.metadata.item(`TankEntity.${id}`);
|
||||||
|
const tankCatalog = item.TankCatalog();
|
||||||
|
|
||||||
|
return tankCatalog;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
go to <a href="/tanks">/tanks</a>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
import type { GetStaticPaths } from "astro";
|
||||||
|
import { api } from "../../../core/api/dynamic";
|
||||||
|
|
||||||
|
export const getStaticPaths = (async () => {
|
||||||
|
const { tanks } = await api.tanks();
|
||||||
|
|
||||||
|
return tanks.map((tank) => ({
|
||||||
|
params: { slug: tank.slug },
|
||||||
|
props: { id: tank.id },
|
||||||
|
}));
|
||||||
|
}) satisfies GetStaticPaths;
|
||||||
|
|
||||||
|
const { id } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<h1>Tank {id}</h1>
|
||||||
|
|
||||||
|
<div style="max-height: 40rem; overflow-y: scroll">
|
||||||
|
<code>
|
||||||
|
<pre>{JSON.stringify( await api.tank(id) , null, 2)}</pre>
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
import { api } from "../../core/api/dynamic";
|
||||||
|
|
||||||
|
const tanksList = await api.tanks();
|
||||||
|
---
|
||||||
|
|
||||||
|
<h1>Tanks</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{
|
||||||
|
tanksList.tanks.map(({ id, slug }) => (
|
||||||
|
<li>
|
||||||
|
<a href={`/tanks/${slug}`}>
|
||||||
|
{slug} ({id})
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package blitzkit;
|
||||||
|
|
||||||
|
message Tanks {
|
||||||
|
repeated TanksEntry tanks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TanksEntry {
|
||||||
|
string id = 1;
|
||||||
|
string slug = 2;
|
||||||
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"]
|
"extends": ["../../tsconfig.json", "astro/tsconfigs/base"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"paths": {
|
||||||
|
"@protos/*": ["../../packages/closed/protos/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user