mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
299 lines
9.1 KiB
TypeScript
299 lines
9.1 KiB
TypeScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
// versions:
|
|
// protoc-gen-ts_proto v2.2.2
|
|
// protoc v5.28.2
|
|
// source: packages/core/src/protos/map_definitions.proto
|
|
|
|
/* eslint-disable */
|
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
import { I18nString, createBaseI18nString } from "./i18n";
|
|
|
|
export const protobufPackage = "blitzkit";
|
|
|
|
export interface MapDefinitions {
|
|
maps: { [key: number]: MapDefinition };
|
|
}
|
|
|
|
export interface MapDefinitions_MapsEntry {
|
|
key: number;
|
|
value: MapDefinition | undefined;
|
|
}
|
|
|
|
export interface MapDefinition {
|
|
id: number;
|
|
name: I18nString;
|
|
}
|
|
|
|
function createBaseMapDefinitions(): MapDefinitions {
|
|
return { maps: {} };
|
|
}
|
|
|
|
export const MapDefinitions: MessageFns<MapDefinitions> = {
|
|
encode(message: MapDefinitions, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
Object.entries(message.maps).forEach(([key, value]) => {
|
|
MapDefinitions_MapsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
|
|
});
|
|
return writer;
|
|
},
|
|
|
|
decode(input: BinaryReader | Uint8Array, length?: number): MapDefinitions {
|
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
const message = createBaseMapDefinitions();
|
|
while (reader.pos < end) {
|
|
const tag = reader.uint32();
|
|
switch (tag >>> 3) {
|
|
case 1: {
|
|
if (tag !== 10) {
|
|
break;
|
|
}
|
|
|
|
const entry1 = MapDefinitions_MapsEntry.decode(reader, reader.uint32());
|
|
if (entry1.value !== undefined) {
|
|
message.maps[entry1.key] = entry1.value;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
if ((tag & 7) === 4 || tag === 0) {
|
|
break;
|
|
}
|
|
reader.skip(tag & 7);
|
|
}
|
|
return message;
|
|
},
|
|
|
|
fromJSON(object: any): MapDefinitions {
|
|
return {
|
|
maps: isObject(object.maps)
|
|
? Object.entries(object.maps).reduce<{ [key: number]: MapDefinition }>((acc, [key, value]) => {
|
|
acc[globalThis.Number(key)] = MapDefinition.fromJSON(value);
|
|
return acc;
|
|
}, {})
|
|
: {},
|
|
};
|
|
},
|
|
|
|
toJSON(message: MapDefinitions): unknown {
|
|
const obj: any = {};
|
|
if (message.maps) {
|
|
const entries = Object.entries(message.maps);
|
|
if (entries.length > 0) {
|
|
obj.maps = {};
|
|
entries.forEach(([k, v]) => {
|
|
obj.maps[k] = MapDefinition.toJSON(v);
|
|
});
|
|
}
|
|
}
|
|
return obj;
|
|
},
|
|
|
|
create<I extends Exact<DeepPartial<MapDefinitions>, I>>(base?: I): MapDefinitions {
|
|
return MapDefinitions.fromPartial(base ?? ({} as any));
|
|
},
|
|
fromPartial<I extends Exact<DeepPartial<MapDefinitions>, I>>(object: I): MapDefinitions {
|
|
const message = createBaseMapDefinitions();
|
|
message.maps = Object.entries(object.maps ?? {}).reduce<{ [key: number]: MapDefinition }>((acc, [key, value]) => {
|
|
if (value !== undefined) {
|
|
acc[globalThis.Number(key)] = MapDefinition.fromPartial(value);
|
|
}
|
|
return acc;
|
|
}, {});
|
|
return message;
|
|
},
|
|
};
|
|
|
|
function createBaseMapDefinitions_MapsEntry(): MapDefinitions_MapsEntry {
|
|
return { key: 0, value: createBaseMapDefinition() };
|
|
}
|
|
|
|
export const MapDefinitions_MapsEntry: MessageFns<MapDefinitions_MapsEntry> = {
|
|
encode(message: MapDefinitions_MapsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
if (message.key !== undefined) {
|
|
writer.uint32(8).int32(message.key);
|
|
}
|
|
if (message.value !== undefined) {
|
|
MapDefinition.encode(message.value, writer.uint32(18).fork()).join();
|
|
}
|
|
return writer;
|
|
},
|
|
|
|
decode(input: BinaryReader | Uint8Array, length?: number): MapDefinitions_MapsEntry {
|
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
const message = createBaseMapDefinitions_MapsEntry();
|
|
while (reader.pos < end) {
|
|
const tag = reader.uint32();
|
|
switch (tag >>> 3) {
|
|
case 1: {
|
|
if (tag !== 8) {
|
|
break;
|
|
}
|
|
|
|
message.key = reader.int32();
|
|
continue;
|
|
}
|
|
case 2: {
|
|
if (tag !== 18) {
|
|
break;
|
|
}
|
|
|
|
message.value = MapDefinition.decode(reader, reader.uint32());
|
|
continue;
|
|
}
|
|
}
|
|
if ((tag & 7) === 4 || tag === 0) {
|
|
break;
|
|
}
|
|
reader.skip(tag & 7);
|
|
}
|
|
return message;
|
|
},
|
|
|
|
fromJSON(object: any): MapDefinitions_MapsEntry {
|
|
return {
|
|
key: globalThis.Number(assertSet("MapDefinitions_MapsEntry.key", object.key)),
|
|
value: MapDefinition.fromJSON(assertSet("MapDefinitions_MapsEntry.value", object.value)),
|
|
};
|
|
},
|
|
|
|
toJSON(message: MapDefinitions_MapsEntry): unknown {
|
|
const obj: any = {};
|
|
if (message.key !== undefined) {
|
|
obj.key = Math.round(message.key);
|
|
}
|
|
if (message.value !== undefined) {
|
|
obj.value = MapDefinition.toJSON(message.value);
|
|
}
|
|
return obj;
|
|
},
|
|
|
|
create<I extends Exact<DeepPartial<MapDefinitions_MapsEntry>, I>>(base?: I): MapDefinitions_MapsEntry {
|
|
return MapDefinitions_MapsEntry.fromPartial(base ?? ({} as any));
|
|
},
|
|
fromPartial<I extends Exact<DeepPartial<MapDefinitions_MapsEntry>, I>>(object: I): MapDefinitions_MapsEntry {
|
|
const message = createBaseMapDefinitions_MapsEntry();
|
|
message.key = object.key ?? 0;
|
|
message.value = (object.value !== undefined && object.value !== null)
|
|
? MapDefinition.fromPartial(object.value)
|
|
: undefined;
|
|
return message;
|
|
},
|
|
};
|
|
|
|
function createBaseMapDefinition(): MapDefinition {
|
|
return { id: 0, name: createBaseI18nString() };
|
|
}
|
|
|
|
export const MapDefinition: MessageFns<MapDefinition> = {
|
|
encode(message: MapDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
if (message.id !== 0) {
|
|
writer.uint32(8).uint32(message.id);
|
|
}
|
|
if (message.name !== undefined) {
|
|
I18nString.encode(message.name, writer.uint32(18).fork()).join();
|
|
}
|
|
return writer;
|
|
},
|
|
|
|
decode(input: BinaryReader | Uint8Array, length?: number): MapDefinition {
|
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
const message = createBaseMapDefinition();
|
|
while (reader.pos < end) {
|
|
const tag = reader.uint32();
|
|
switch (tag >>> 3) {
|
|
case 1: {
|
|
if (tag !== 8) {
|
|
break;
|
|
}
|
|
|
|
message.id = reader.uint32();
|
|
continue;
|
|
}
|
|
case 2: {
|
|
if (tag !== 18) {
|
|
break;
|
|
}
|
|
|
|
message.name = I18nString.decode(reader, reader.uint32());
|
|
continue;
|
|
}
|
|
}
|
|
if ((tag & 7) === 4 || tag === 0) {
|
|
break;
|
|
}
|
|
reader.skip(tag & 7);
|
|
}
|
|
return message;
|
|
},
|
|
|
|
fromJSON(object: any): MapDefinition {
|
|
return {
|
|
id: globalThis.Number(assertSet("MapDefinition.id", object.id)),
|
|
name: I18nString.fromJSON(assertSet("MapDefinition.name", object.name)),
|
|
};
|
|
},
|
|
|
|
toJSON(message: MapDefinition): unknown {
|
|
const obj: any = {};
|
|
if (message.id !== 0) {
|
|
obj.id = Math.round(message.id);
|
|
}
|
|
if (message.name !== undefined) {
|
|
obj.name = I18nString.toJSON(message.name);
|
|
}
|
|
return obj;
|
|
},
|
|
|
|
create<I extends Exact<DeepPartial<MapDefinition>, I>>(base?: I): MapDefinition {
|
|
return MapDefinition.fromPartial(base ?? ({} as any));
|
|
},
|
|
fromPartial<I extends Exact<DeepPartial<MapDefinition>, I>>(object: I): MapDefinition {
|
|
const message = createBaseMapDefinition();
|
|
message.id = object.id ?? 0;
|
|
message.name = (object.name !== undefined && object.name !== null)
|
|
? I18nString.fromPartial(object.name)
|
|
: createBaseI18nString();
|
|
return message;
|
|
},
|
|
};
|
|
|
|
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>;
|
|
|
|
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 };
|
|
|
|
function isObject(value: any): boolean {
|
|
return typeof value === "object" && value !== null;
|
|
}
|
|
|
|
function isSet(value: any): boolean {
|
|
return value !== null && value !== undefined;
|
|
}
|
|
|
|
function assertSet<T>(field: string, value: T | undefined): T {
|
|
if (!isSet(value)) {
|
|
throw new TypeError(`Required field ${field} is not set`);
|
|
}
|
|
|
|
return value as T;
|
|
}
|
|
|
|
export interface MessageFns<T> {
|
|
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
fromJSON(object: any): T;
|
|
toJSON(message: T): unknown;
|
|
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
}
|