mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: type errors in definitions
This commit is contained in:
1 parent
3e18d5a8db
commit
61fe8c7e7c
22 files changed
+1728
-1692
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import { AverageDefinitions } from '../../protos';
|
import { AverageDefinitions } from '../../protos';
|
||||||
|
import { fetchPB } from '../../types';
|
||||||
import { asset } from '../asset';
|
import { asset } from '../asset';
|
||||||
|
|
||||||
export interface AverageDefinitionsManifest {
|
export interface AverageDefinitionsManifest {
|
||||||
@@ -13,14 +14,10 @@ export async function fetchAverageDefinitions() {
|
|||||||
const manifestResponse = await fetch(asset('averages/manifest.json'));
|
const manifestResponse = await fetch(asset('averages/manifest.json'));
|
||||||
const manifestJson =
|
const manifestJson =
|
||||||
(await manifestResponse.json()) as AverageDefinitionsManifest;
|
(await manifestResponse.json()) as AverageDefinitionsManifest;
|
||||||
const averageDefinitionsResponse = await fetch(
|
return await fetchPB(
|
||||||
asset(`averages/${manifestJson.latest}.pb`),
|
asset(`averages/${manifestJson.latest}.pb`),
|
||||||
|
AverageDefinitions,
|
||||||
);
|
);
|
||||||
const averageDefinitionsBuffer =
|
|
||||||
await averageDefinitionsResponse.arrayBuffer();
|
|
||||||
const averageDefinitionsArray = new Uint8Array(averageDefinitionsBuffer);
|
|
||||||
|
|
||||||
return AverageDefinitions.deserializeBinary(averageDefinitionsArray);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from './constants';
|
export * from './constants';
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { CamouflageDefinitions } from '../protos';
|
import { CamouflageDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchCamouflageDefinitions() {
|
export function fetchCamouflageDefinitions() {
|
||||||
const response = await fetch(asset('definitions/camoufles.pb'));
|
return fetchPB(asset('definitions/camoufles.pb'), CamouflageDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return CamouflageDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { ConsumableDefinitions } from '../protos';
|
import { ConsumableDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchConsumableDefinitions() {
|
export function fetchConsumableDefinitions() {
|
||||||
const response = await fetch(asset('definitions/consumables.pb'));
|
return fetchPB(asset('definitions/consumables.pb'), ConsumableDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return ConsumableDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { EquipmentDefinitions } from '../protos';
|
import { EquipmentDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchEquipmentDefinitions() {
|
export function fetchEquipmentDefinitions() {
|
||||||
const response = await fetch(asset('definitions/equipment.pb'));
|
return fetchPB(asset('definitions/equipment.pb'), EquipmentDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return EquipmentDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { GameDefinitions } from '../protos';
|
import { GameDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchGameDefinitions() {
|
export function fetchGameDefinitions() {
|
||||||
const response = await fetch(asset('definitions/game.pb'));
|
return fetchPB(asset('definitions/game.pb'), GameDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return GameDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,7 @@
|
|||||||
|
import { MapDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { fetchCdonLz4 } from './fetchCdonLz4';
|
|
||||||
|
|
||||||
export interface MapDefinitions {
|
export function fetchMapDefinitions() {
|
||||||
[id: number]: {
|
return fetchPB(asset('definitions/maps.pb'), MapDefinitions);
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapDefinitions = fetchCdonLz4<MapDefinitions>(
|
|
||||||
asset('definitions/maps.cdon.lz4'),
|
|
||||||
);
|
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { ModelDefinitions } from '../protos';
|
import { ModelDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchModelDefinitions() {
|
export function fetchModelDefinitions() {
|
||||||
const response = await fetch(asset('definitions/models.pb'));
|
return fetchPB(asset('definitions/models.pb'), ModelDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return ModelDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { ProvisionDefinitions } from '../protos';
|
import { ProvisionDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchProvisionDefinitions() {
|
export function fetchProvisionDefinitions() {
|
||||||
const response = await fetch(asset('definitions/provisions.pb'));
|
return fetchPB(asset('definitions/provisions.pb'), ProvisionDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return ProvisionDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { Reviews } from '../protos';
|
import { Reviews } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchReviews() {
|
export function fetchReviews() {
|
||||||
const response = await fetch(asset('definitions/reviews.pb'));
|
return fetchPB(asset('definitions/reviews.pb'), Reviews);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return Reviews.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
import { SkillDefinitions } from '../protos';
|
import { SkillDefinitions } from '../protos';
|
||||||
|
import { fetchPB } from '../types';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export async function fetchSkillDefinitions() {
|
export function fetchSkillDefinitions() {
|
||||||
const response = await fetch(asset('definitions/skills.pb'));
|
return fetchPB(asset('definitions/skills.pb'), SkillDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return SkillDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
import { TankDefinitions } from '../../protos';
|
import { TankDefinitions } from '../../protos';
|
||||||
|
import { fetchPB } from '../../types';
|
||||||
import { asset } from '../asset';
|
import { asset } from '../asset';
|
||||||
|
|
||||||
export async function fetchTankDefinitions() {
|
export function fetchTankDefinitions() {
|
||||||
const response = await fetch(asset('definitions/tanks.pb'));
|
return fetchPB(asset('definitions/tanks.pb'), TankDefinitions);
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
return TankDefinitions.deserializeBinary(array).toObject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from './constants';
|
export * from './constants';
|
||||||
+10
-10
@@ -1,11 +1,11 @@
|
|||||||
// export * from './blitz';
|
export * from './blitz';
|
||||||
// export * from './blitzkit';
|
export * from './blitzkit';
|
||||||
|
export * from './databases';
|
||||||
|
export * from './imgur';
|
||||||
|
export * from './math';
|
||||||
|
export * from './patreon';
|
||||||
|
export * from './protobuf';
|
||||||
export * from './protos';
|
export * from './protos';
|
||||||
// export * from './blitzstars';
|
export * from './statistics';
|
||||||
// export * from './databases';
|
export * from './streams';
|
||||||
// export * from './imgur';
|
export * from './types';
|
||||||
// export * from './math';
|
|
||||||
// export * from './patreon';
|
|
||||||
// export * from './statistics';
|
|
||||||
// export * from './streams';
|
|
||||||
// export * from './types';
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { MessageFns } from '../protos';
|
||||||
|
|
||||||
|
export function encodePB64<Type>(message: MessageFns<Type>, data: Type) {
|
||||||
|
return Buffer.from(message.encode(data).finish()).toString('base64');
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { MessageFns } from '../protos';
|
||||||
|
|
||||||
|
export async function fetchPB<Type>(url: string, message: MessageFns<Type>) {
|
||||||
|
const response = await fetch(url);
|
||||||
|
const buffer = await response.arrayBuffer();
|
||||||
|
const array = new Uint8Array(buffer);
|
||||||
|
return message.decode(array);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './encodePB64';
|
||||||
|
export * from './fetchPB';
|
||||||
|
export * from './pbMap';
|
||||||
File renamed without changes.
@@ -20,10 +20,10 @@ message Consumable {
|
|||||||
|
|
||||||
message ConsumableTankFilter {
|
message ConsumableTankFilter {
|
||||||
oneof filter_type {
|
oneof filter_type {
|
||||||
ConsumableTankTierFilter tier = 1;
|
ConsumableTankTierFilter tiers = 1;
|
||||||
ConsumableTankIdsFilter ids = 2;
|
ConsumableTankIdsFilter ids = 2;
|
||||||
ConsumableTankCategoryFilter category = 3;
|
ConsumableTankCategoryFilter categories = 3;
|
||||||
ConsumableTankNationFilter nation = 4;
|
ConsumableTankNationFilter nations = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,8 +41,7 @@ message ConsumableTankCategoryFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ConsumableTankCategoryFilterCategory {
|
enum ConsumableTankCategoryFilterCategory {
|
||||||
TANK_CATEGORY_UNSPECIFIED = 0;
|
TANK_CATEGORY_CLIP = 0;
|
||||||
TANK_CATEGORY_CLIP = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConsumableTankNationFilter {
|
message ConsumableTankNationFilter {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package blitzkit;
|
||||||
|
|
||||||
|
message MapDefinitions {
|
||||||
|
map<int32, MapDefinition> maps = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MapDefinition {
|
||||||
|
uint32 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
@@ -41,9 +41,8 @@ message TankDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum TankPriceType {
|
enum TankPriceType {
|
||||||
TANK_PRICE_TYPE_UNSPECIFIED = 0;
|
TANK_PRICE_TYPE_CREDITS = 0;
|
||||||
TANK_PRICE_TYPE_CREDITS = 1;
|
TANK_PRICE_TYPE_GOLD = 1;
|
||||||
TANK_PRICE_TYPE_GOLD = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message TankPrice {
|
message TankPrice {
|
||||||
@@ -162,11 +161,10 @@ message ShellDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ShellType {
|
enum ShellType {
|
||||||
SHELL_TYPE_UNSPECIFIED = 0;
|
SHELL_TYPE_AP = 0;
|
||||||
SHELL_TYPE_AP = 1;
|
SHELL_TYPE_APCR = 1;
|
||||||
SHELL_TYPE_APCR = 2;
|
SHELL_TYPE_HEAT = 2;
|
||||||
SHELL_TYPE_HEAT = 3;
|
SHELL_TYPE_HE = 3;
|
||||||
SHELL_TYPE_HE = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ShellPenetration {
|
message ShellPenetration {
|
||||||
@@ -186,41 +184,37 @@ message UnlockCost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ModuleType {
|
enum ModuleType {
|
||||||
MODULE_TYPE_UNSPECIFIED = 0;
|
MODULE_TYPE_VEHICLE = 0;
|
||||||
MODULE_TYPE_VEHICLE = 1;
|
MODULE_TYPE_ENGINE = 1;
|
||||||
MODULE_TYPE_ENGINE = 2;
|
MODULE_TYPE_TRACKS = 2;
|
||||||
MODULE_TYPE_TRACKS = 3;
|
MODULE_TYPE_TURRET = 3;
|
||||||
MODULE_TYPE_TURRET = 4;
|
MODULE_TYPE_GUN = 4;
|
||||||
MODULE_TYPE_GUN = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TankClass {
|
enum TankClass {
|
||||||
TANK_CLASS_UNSPECIFIED = 0;
|
TANK_CLASS_LIGHT = 0;
|
||||||
TANK_CLASS_LIGHT = 1;
|
TANK_CLASS_MEDIUM = 1;
|
||||||
TANK_CLASS_MEDIUM = 2;
|
TANK_CLASS_HEAVY = 2;
|
||||||
TANK_CLASS_HEAVY = 3;
|
TANK_CLASS_TANK_DESTROYER = 3;
|
||||||
TANK_CLASS_TANK_DESTROYER = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Tier {
|
enum Tier {
|
||||||
TIER_UNSPECIFIED = 0;
|
TIER_I = 0;
|
||||||
TIER_I = 1;
|
TIER_II = 1;
|
||||||
TIER_II = 2;
|
TIER_III = 2;
|
||||||
TIER_III = 3;
|
TIER_IV = 3;
|
||||||
TIER_IV = 4;
|
TIER_V = 4;
|
||||||
TIER_V = 5;
|
TIER_VI = 5;
|
||||||
TIER_VI = 6;
|
TIER_VII = 6;
|
||||||
TIER_VII = 7;
|
TIER_VIII = 7;
|
||||||
TIER_VIII = 8;
|
TIER_IX = 8;
|
||||||
TIER_IX = 9;
|
TIER_X = 9;
|
||||||
TIER_X = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TankType {
|
enum TankType {
|
||||||
TANK_TYPE_UNSPECIFIED = 0;
|
TANK_TYPE_RESEARCHABLE = 0;
|
||||||
TANK_TYPE_RESEARCHABLE = 1;
|
TANK_TYPE_PREMIUM = 1;
|
||||||
TANK_TYPE_PREMIUM = 2;
|
TANK_TYPE_COLLECTOR = 2;
|
||||||
TANK_TYPE_COLLECTOR = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Crew {
|
message Crew {
|
||||||
@@ -230,10 +224,9 @@ message Crew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum CrewType {
|
enum CrewType {
|
||||||
CREW_TYPE_UNSPECIFIED = 0;
|
CREW_TYPE_COMMANDER = 0;
|
||||||
CREW_TYPE_COMMANDER = 1;
|
CREW_TYPE_RADIOMAN = 1;
|
||||||
CREW_TYPE_RADIOMAN = 2;
|
CREW_TYPE_GUNNER = 2;
|
||||||
CREW_TYPE_GUNNER = 3;
|
CREW_TYPE_DRIVER = 3;
|
||||||
CREW_TYPE_DRIVER = 4;
|
CREW_TYPE_LOADER = 4;
|
||||||
CREW_TYPE_LOADER = 5;
|
|
||||||
}
|
}
|
||||||
@@ -1,2 +1 @@
|
|||||||
export * from './pbMap';
|
|
||||||
export * from './tanksStats';
|
export * from './tanksStats';
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user