mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: name fetching
This commit is contained in:
1 parent
18d762c41b
commit
35894f39cf
5 files changed
+144
-63
No files matched your search
@@ -46,5 +46,6 @@ export * from './votes';
|
||||
export * from './createDefaultProvisions';
|
||||
export * from './metaSortTank';
|
||||
export * from './romanize';
|
||||
export * from './tank';
|
||||
export * from './tanks';
|
||||
export * from './youtubers';
|
||||
@@ -0,0 +1,7 @@
|
||||
import { fetchPB } from '../protobuf';
|
||||
import { Tank } from '../protos';
|
||||
import { asset } from './asset';
|
||||
|
||||
export function fetchTank(id: string) {
|
||||
return fetchPB(asset(`tanks/${id}/meta.pb`), Tank);
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
// source: packages/core/src/protos/i18n.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
||||
|
||||
export const protobufPackage = "blitzkit";
|
||||
export const protobufPackage = 'blitzkit';
|
||||
|
||||
export interface I18n {
|
||||
locales: { [key: string]: string };
|
||||
@@ -18,20 +18,27 @@ export interface I18n_LocalesEntry {
|
||||
value: string;
|
||||
}
|
||||
|
||||
function createBaseI18n(): I18n {
|
||||
export function createBaseI18n(): I18n {
|
||||
return { locales: {} };
|
||||
}
|
||||
|
||||
export const I18n: MessageFns<I18n> = {
|
||||
encode(message: I18n, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
encode(
|
||||
message: I18n,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
Object.entries(message.locales).forEach(([key, value]) => {
|
||||
I18n_LocalesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
|
||||
I18n_LocalesEntry.encode(
|
||||
{ key: key as any, value },
|
||||
writer.uint32(10).fork(),
|
||||
).join();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): I18n {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseI18n();
|
||||
while (reader.pos < end) {
|
||||
@@ -60,10 +67,13 @@ export const I18n: MessageFns<I18n> = {
|
||||
fromJSON(object: any): I18n {
|
||||
return {
|
||||
locales: isObject(object.locales)
|
||||
? Object.entries(object.locales).reduce<{ [key: string]: string }>((acc, [key, value]) => {
|
||||
acc[key] = String(value);
|
||||
return acc;
|
||||
}, {})
|
||||
? Object.entries(object.locales).reduce<{ [key: string]: string }>(
|
||||
(acc, [key, value]) => {
|
||||
acc[key] = String(value);
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
)
|
||||
: {},
|
||||
};
|
||||
},
|
||||
@@ -87,7 +97,9 @@ export const I18n: MessageFns<I18n> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<I18n>, I>>(object: I): I18n {
|
||||
const message = createBaseI18n();
|
||||
message.locales = Object.entries(object.locales ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => {
|
||||
message.locales = Object.entries(object.locales ?? {}).reduce<{
|
||||
[key: string]: string;
|
||||
}>((acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
acc[key] = globalThis.String(value);
|
||||
}
|
||||
@@ -98,11 +110,14 @@ export const I18n: MessageFns<I18n> = {
|
||||
};
|
||||
|
||||
function createBaseI18n_LocalesEntry(): I18n_LocalesEntry {
|
||||
return { key: "", value: "" };
|
||||
return { key: '', value: '' };
|
||||
}
|
||||
|
||||
export const I18n_LocalesEntry: MessageFns<I18n_LocalesEntry> = {
|
||||
encode(message: I18n_LocalesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
encode(
|
||||
message: I18n_LocalesEntry,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
if (message.key !== undefined) {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
@@ -113,7 +128,8 @@ export const I18n_LocalesEntry: MessageFns<I18n_LocalesEntry> = {
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): I18n_LocalesEntry {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseI18n_LocalesEntry();
|
||||
while (reader.pos < end) {
|
||||
@@ -146,8 +162,10 @@ export const I18n_LocalesEntry: MessageFns<I18n_LocalesEntry> = {
|
||||
|
||||
fromJSON(object: any): I18n_LocalesEntry {
|
||||
return {
|
||||
key: globalThis.String(assertSet("I18n_LocalesEntry.key", object.key)),
|
||||
value: globalThis.String(assertSet("I18n_LocalesEntry.value", object.value)),
|
||||
key: globalThis.String(assertSet('I18n_LocalesEntry.key', object.key)),
|
||||
value: globalThis.String(
|
||||
assertSet('I18n_LocalesEntry.value', object.value),
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
@@ -162,32 +180,51 @@ export const I18n_LocalesEntry: MessageFns<I18n_LocalesEntry> = {
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(base?: I): I18n_LocalesEntry {
|
||||
create<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(
|
||||
base?: I,
|
||||
): I18n_LocalesEntry {
|
||||
return I18n_LocalesEntry.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(object: I): I18n_LocalesEntry {
|
||||
fromPartial<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(
|
||||
object: I,
|
||||
): I18n_LocalesEntry {
|
||||
const message = createBaseI18n_LocalesEntry();
|
||||
message.key = object.key ?? "";
|
||||
message.value = object.value ?? "";
|
||||
message.key = object.key ?? '';
|
||||
message.value = object.value ?? '';
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends globalThis.Array<infer U>
|
||||
? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown }
|
||||
? { $case: T['$case']; value?: DeepPartial<T['value']> }
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
|
||||
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
||||
};
|
||||
|
||||
function isObject(value: any): boolean {
|
||||
return typeof value === "object" && value !== null;
|
||||
return typeof value === 'object' && value !== null;
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
// source: packages/core/src/protos/tank.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { I18n } from "./i18n";
|
||||
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
||||
import { I18n, createBaseI18n } from './i18n';
|
||||
|
||||
export const protobufPackage = "blitzkit";
|
||||
export const protobufPackage = 'blitzkit';
|
||||
|
||||
export interface Tank {
|
||||
id: string;
|
||||
@@ -17,15 +17,18 @@ export interface Tank {
|
||||
}
|
||||
|
||||
function createBaseTank(): Tank {
|
||||
return { id: "", slug: "", name: createBaseI18n() };
|
||||
return { id: '', slug: '', name: createBaseI18n() };
|
||||
}
|
||||
|
||||
export const Tank: MessageFns<Tank> = {
|
||||
encode(message: Tank, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.id !== "") {
|
||||
encode(
|
||||
message: Tank,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
if (message.id !== '') {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
if (message.slug !== '') {
|
||||
writer.uint32(18).string(message.slug);
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
@@ -35,7 +38,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): Tank {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTank();
|
||||
while (reader.pos < end) {
|
||||
@@ -76,18 +80,18 @@ export const Tank: MessageFns<Tank> = {
|
||||
|
||||
fromJSON(object: any): Tank {
|
||||
return {
|
||||
id: globalThis.String(assertSet("Tank.id", object.id)),
|
||||
slug: globalThis.String(assertSet("Tank.slug", object.slug)),
|
||||
name: I18n.fromJSON(assertSet("Tank.name", object.name)),
|
||||
id: globalThis.String(assertSet('Tank.id', object.id)),
|
||||
slug: globalThis.String(assertSet('Tank.slug', object.slug)),
|
||||
name: I18n.fromJSON(assertSet('Tank.name', object.name)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Tank): unknown {
|
||||
const obj: any = {};
|
||||
if (message.id !== "") {
|
||||
if (message.id !== '') {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.slug !== "") {
|
||||
if (message.slug !== '') {
|
||||
obj.slug = message.slug;
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
@@ -101,27 +105,43 @@ export const Tank: MessageFns<Tank> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<Tank>, I>>(object: I): Tank {
|
||||
const message = createBaseTank();
|
||||
message.id = object.id ?? "";
|
||||
message.slug = object.slug ?? "";
|
||||
message.name = (object.name !== undefined && object.name !== null)
|
||||
? I18n.fromPartial(object.name)
|
||||
: createBaseI18n();
|
||||
message.id = object.id ?? '';
|
||||
message.slug = object.slug ?? '';
|
||||
message.name =
|
||||
object.name !== undefined && object.name !== null
|
||||
? I18n.fromPartial(object.name)
|
||||
: createBaseI18n();
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends globalThis.Array<infer U>
|
||||
? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown }
|
||||
? { $case: T['$case']; value?: DeepPartial<T['value']> }
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
|
||||
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
||||
};
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
|
||||
Reference in new issue
Block a user