diff --git a/.gitignore b/.gitignore index 9e20f4a27..baf7dd05e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ depots public/sitemap* /firebase.json target -# packages/core/src/protos/*.ts +packages/website-ue/src/protos/*.ts /.vercel .astro .vercel diff --git a/packages/closed b/packages/closed index 5b4a85d50..2c0b66070 160000 --- a/packages/closed +++ b/packages/closed @@ -1 +1 @@ -Subproject commit 5b4a85d503ca2bec859f856b26762c8fea33d545 +Subproject commit 2c0b660702839f12350810a05be42625da5e45ab diff --git a/packages/scripts/src/protos.ts b/packages/scripts/src/protos.ts index 22e92f18f..92939a171 100644 --- a/packages/scripts/src/protos.ts +++ b/packages/scripts/src/protos.ts @@ -11,7 +11,8 @@ const TS_PROTO_EXECUTABLE_LOCATIONS = [ const roots = [ // "../../packages/core/src/protos", - "../../packages/closed/protos", + // "../../packages/closed/protos", + "../../packages/website-ue/src/protos", ]; const exec = promisify(execSync); diff --git a/packages/website-ue/src/core/api/abstract.ts b/packages/website-ue/src/core/api/abstract.ts index aefd47589..4a3bf8b3e 100644 --- a/packages/website-ue/src/core/api/abstract.ts +++ b/packages/website-ue/src/core/api/abstract.ts @@ -1 +1,5 @@ -abstract class AbstractAPI {} +import type { Tanks } from "../../protos/tanks"; + +export abstract class AbstractAPI { + abstract tanks(): Promise; +} diff --git a/packages/website-ue/src/core/api/client.ts b/packages/website-ue/src/core/api/client.ts index 79d0f7d11..0c86e6eb6 100644 --- a/packages/website-ue/src/core/api/client.ts +++ b/packages/website-ue/src/core/api/client.ts @@ -1 +1,3 @@ +import { AbstractAPI } from "./abstract"; + export class ClientAPI extends AbstractAPI {} diff --git a/packages/website-ue/src/core/api/dynamic.ts b/packages/website-ue/src/core/api/dynamic.ts index 2323ee53f..6c881ce61 100644 --- a/packages/website-ue/src/core/api/dynamic.ts +++ b/packages/website-ue/src/core/api/dynamic.ts @@ -1,11 +1,20 @@ -import { ClientAPI } from "./client"; -import { ServerAPI } from "./server"; +import type { AbstractAPI } from "./abstract"; let dynamicAPI: AbstractAPI; if (typeof window === "undefined") { - dynamicAPI = new ServerAPI(); + 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(); } diff --git a/packages/website-ue/src/core/api/server.ts b/packages/website-ue/src/core/api/server.ts index 448ffe6fa..b1776c3f3 100644 --- a/packages/website-ue/src/core/api/server.ts +++ b/packages/website-ue/src/core/api/server.ts @@ -1 +1,27 @@ -export class ServerAPI extends AbstractAPI {} +import type { MetadataAccessor } from "@blitzkit/closed"; +import type { TanksEntry } from "../../protos/tanks"; +import { AbstractAPI } from "./abstract"; + +export class ServerAPI extends AbstractAPI { + constructor(private metadata: MetadataAccessor) { + super(); + + console.log(Object.keys(metadata.groups).join("\n")); + } + + async tanks() { + const group = this.metadata.group("TankEntity"); + const tanks: TanksEntry[] = []; + + for (const item of group) { + const tankCatalog = item.TankCatalog(); + + const id = item.id; + const slug = tankCatalog.name?.value; + + tanks.push({ id, slug }); + } + + return { tanks }; + } +} diff --git a/packages/website-ue/src/core/blitz/proxyClient.ts b/packages/website-ue/src/core/blitz/proxyClient.ts deleted file mode 100644 index f21ab0d34..000000000 --- a/packages/website-ue/src/core/blitz/proxyClient.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ProxyClient } from "@blitzkit/closed"; - -export const proxyClient = await new ProxyClient( - import.meta.env.WOTB_SERVER -).handshake(); - -export const metadata = await proxyClient.metadata(); diff --git a/packages/website-ue/src/pages/tanks/index.astro b/packages/website-ue/src/pages/tanks/index.astro index 77ae79c8f..8aa6eb2e4 100644 --- a/packages/website-ue/src/pages/tanks/index.astro +++ b/packages/website-ue/src/pages/tanks/index.astro @@ -1,16 +1,18 @@ --- import { api } from "../../core/api/dynamic"; -const tanksList = await api.tanksList(); +const tanksList = await api.tanks(); ---

Tanks