feat & fix: feat proto & revert NapProto changes

This commit is contained in:
pk5ls20 committed 2024-10-13 16:13:34 +08:00
1 parent b4e22a345d
commit d21da47a7d
6 files changed
+19 -17

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
import { MessageType, RepeatType, ScalarType } from '@protobuf-ts/runtime';
import { MessageType, PartialMessage, RepeatType, ScalarType } from '@protobuf-ts/runtime';
import { PartialFieldInfo } from "@protobuf-ts/runtime/build/types/reflection-info";
type LowerCamelCase<S extends string> = CamelCaseHelper<S, false, true>;
@@ -122,7 +122,7 @@ export class NapProtoMsg<T extends ProtoMessageType> {
no: field.no,
name: key,
kind: 'message',
repeat: field.repeat ? RepeatType.UNPACKED : RepeatType.NO,
repeat: field.repeat ? RepeatType.PACKED : RepeatType.NO,
T: () => rt,
};
}
@@ -131,7 +131,7 @@ export class NapProtoMsg<T extends ProtoMessageType> {
}
encode(data: ProtoStructType<T, true>): Uint8Array {
return this._proto_msg.toBinary(data)
return this._proto_msg.toBinary(this._proto_msg.create(data as PartialMessage<ProtoStructType<T, boolean>>));
}
decode(data: Uint8Array): ProtoStructType<T, false> {