*Update protobuf
This commit is contained in:
parent
ebaba22213
commit
7b920bf2f5
|
@ -10,14 +10,13 @@
|
||||||
"protomux-rpc": "^1.3.0"
|
"protomux-rpc": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@protobuf-ts/plugin": "^2.8.1",
|
"@protobuf-ts/plugin": "^2.8.2",
|
||||||
"@types/b4a": "^1.6.0",
|
"@types/b4a": "^1.6.0",
|
||||||
"@types/debug": "^4.1.7",
|
"@types/debug": "^4.1.7",
|
||||||
"b4a": "^1.6.1",
|
"b4a": "^1.6.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"hyperswarm": "^4.3.5",
|
"hyperswarm": "^4.3.5",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"protoc": "^1.1.3",
|
|
||||||
"sleep-promise": "^9.1.0",
|
"sleep-promise": "^9.1.0",
|
||||||
"sodium-universal": "^3.1.0",
|
"sodium-universal": "^3.1.0",
|
||||||
"tape": "^5.6.1"
|
"tape": "^5.6.1"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// @generated by protobuf-ts 2.8.1
|
// @generated by protobuf-ts 2.8.2
|
||||||
// @generated from protobuf file "messages.proto" (syntax proto2)
|
// @generated from protobuf file "messages.proto" (syntax proto2)
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||||
|
@ -14,7 +14,7 @@ import { MessageType } from "@protobuf-ts/runtime";
|
||||||
/**
|
/**
|
||||||
* @generated from protobuf message Packet
|
* @generated from protobuf message Packet
|
||||||
*/
|
*/
|
||||||
export interface PacketType {
|
export interface Packet {
|
||||||
/**
|
/**
|
||||||
* @generated from protobuf field: bytes originId = 1;
|
* @generated from protobuf field: bytes originId = 1;
|
||||||
*/
|
*/
|
||||||
|
@ -33,43 +33,24 @@ export interface PacketType {
|
||||||
data: Uint8Array;
|
data: Uint8Array;
|
||||||
}
|
}
|
||||||
// @generated message type with reflection information, may provide speed optimized methods
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
class Packet$Type extends MessageType<PacketType> {
|
class Packet$Type extends MessageType<Packet> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Packet", [
|
super("Packet", [
|
||||||
{ no: 1, name: "originId", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
|
{ no: 1, name: "originId", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
|
||||||
{
|
{ no: 2, name: "messageNumber", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
no: 2,
|
|
||||||
name: "messageNumber",
|
|
||||||
kind: "scalar",
|
|
||||||
T: 13 /*ScalarType.UINT32*/,
|
|
||||||
},
|
|
||||||
{ no: 3, name: "ttl", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
{ no: 3, name: "ttl", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
{ no: 4, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
|
{ no: 4, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
create(value?: PartialMessage<PacketType>): PacketType {
|
create(value?: PartialMessage<Packet>): Packet {
|
||||||
const message = {
|
const message = { originId: new Uint8Array(0), messageNumber: 0, ttl: 0, data: new Uint8Array(0) };
|
||||||
originId: new Uint8Array(0),
|
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
|
||||||
messageNumber: 0,
|
|
||||||
ttl: 0,
|
|
||||||
data: new Uint8Array(0),
|
|
||||||
};
|
|
||||||
globalThis.Object.defineProperty(message, MESSAGE_TYPE, {
|
|
||||||
enumerable: false,
|
|
||||||
value: this,
|
|
||||||
});
|
|
||||||
if (value !== undefined)
|
if (value !== undefined)
|
||||||
reflectionMergePartial<PacketType>(this, message, value);
|
reflectionMergePartial<Packet>(this, message, value);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
internalBinaryRead(
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Packet): Packet {
|
||||||
reader: IBinaryReader,
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
length: number,
|
|
||||||
options: BinaryReadOptions,
|
|
||||||
target?: PacketType
|
|
||||||
): PacketType {
|
|
||||||
let message = target ?? this.create(),
|
|
||||||
end = reader.pos + length;
|
|
||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
let [fieldNo, wireType] = reader.tag();
|
let [fieldNo, wireType] = reader.tag();
|
||||||
switch (fieldNo) {
|
switch (fieldNo) {
|
||||||
|
@ -88,27 +69,15 @@ class Packet$Type extends MessageType<PacketType> {
|
||||||
default:
|
default:
|
||||||
let u = options.readUnknownField;
|
let u = options.readUnknownField;
|
||||||
if (u === "throw")
|
if (u === "throw")
|
||||||
throw new globalThis.Error(
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
|
|
||||||
);
|
|
||||||
let d = reader.skip(wireType);
|
let d = reader.skip(wireType);
|
||||||
if (u !== false)
|
if (u !== false)
|
||||||
(u === true ? UnknownFieldHandler.onRead : u)(
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
this.typeName,
|
|
||||||
message,
|
|
||||||
fieldNo,
|
|
||||||
wireType,
|
|
||||||
d
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
internalBinaryWrite(
|
internalBinaryWrite(message: Packet, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
message: PacketType,
|
|
||||||
writer: IBinaryWriter,
|
|
||||||
options: BinaryWriteOptions
|
|
||||||
): IBinaryWriter {
|
|
||||||
/* bytes originId = 1; */
|
/* bytes originId = 1; */
|
||||||
if (message.originId.length)
|
if (message.originId.length)
|
||||||
writer.tag(1, WireType.LengthDelimited).bytes(message.originId);
|
writer.tag(1, WireType.LengthDelimited).bytes(message.originId);
|
||||||
|
@ -116,17 +85,14 @@ class Packet$Type extends MessageType<PacketType> {
|
||||||
if (message.messageNumber !== 0)
|
if (message.messageNumber !== 0)
|
||||||
writer.tag(2, WireType.Varint).uint32(message.messageNumber);
|
writer.tag(2, WireType.Varint).uint32(message.messageNumber);
|
||||||
/* uint32 ttl = 3; */
|
/* uint32 ttl = 3; */
|
||||||
if (message.ttl !== 0) writer.tag(3, WireType.Varint).uint32(message.ttl);
|
if (message.ttl !== 0)
|
||||||
|
writer.tag(3, WireType.Varint).uint32(message.ttl);
|
||||||
/* bytes data = 4; */
|
/* bytes data = 4; */
|
||||||
if (message.data.length)
|
if (message.data.length)
|
||||||
writer.tag(4, WireType.LengthDelimited).bytes(message.data);
|
writer.tag(4, WireType.LengthDelimited).bytes(message.data);
|
||||||
let u = options.writeUnknownFields;
|
let u = options.writeUnknownFields;
|
||||||
if (u !== false)
|
if (u !== false)
|
||||||
(u == true ? UnknownFieldHandler.onWrite : u)(
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
this.typeName,
|
|
||||||
message,
|
|
||||||
writer
|
|
||||||
);
|
|
||||||
return writer;
|
return writer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue