From 7f084ba77fac82da6fa1994bfae9ef80b8b30927 Mon Sep 17 00:00:00 2001 From: ilikdoge Date: Fri, 17 Mar 2023 13:05:14 -0700 Subject: [PATCH 1/2] perf: use Reader.create Allows protobufjs/minimal to detect the config and optionally use BufferReader if supported. --- integration/angular/simple-message.ts | 2 +- .../simple.ts | 6 +-- integration/async-iterable-services/simple.ts | 6 +-- integration/avoid-import-conflicts/simple.ts | 10 ++-- integration/avoid-import-conflicts/simple2.ts | 2 +- integration/barrel-imports/bar.ts | 2 +- integration/barrel-imports/foo.ts | 2 +- integration/batching-with-context/batching.ts | 28 +++++----- integration/batching/batching.ts | 28 +++++----- .../bytes-node/google/protobuf/wrappers.ts | 18 +++---- integration/bytes-node/point.ts | 2 +- integration/const-enum/const-enum.ts | 4 +- .../enums-as-literals-with-string-enums.ts | 2 +- .../enums-as-literals/enums-as-literals.ts | 2 +- integration/fieldmask/fieldmask.ts | 2 +- .../fieldmask/google/protobuf/field_mask.ts | 2 +- integration/file-suffix/child.pb.ts | 2 +- .../google/protobuf/timestamp.pb.ts | 2 +- integration/file-suffix/parent.pb.ts | 2 +- integration/generic-metadata/hero.ts | 14 ++--- .../simple.ts | 2 +- .../generic-service-definitions/simple.ts | 2 +- integration/global-this/global-this.ts | 4 +- .../google/protobuf/timestamp.ts | 2 +- .../grpc-js-use-date-false.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../grpc-js-use-date-string.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../grpc-js-use-date-true.ts | 2 +- integration/grpc-js/google/protobuf/empty.ts | 2 +- integration/grpc-js/google/protobuf/struct.ts | 8 +-- .../grpc-js/google/protobuf/timestamp.ts | 2 +- .../grpc-js/google/protobuf/wrappers.ts | 18 +++---- integration/grpc-js/simple.ts | 2 +- integration/grpc-web-go-server/example.ts | 26 ++++----- .../example.ts | 8 +-- integration/grpc-web-no-streaming/example.ts | 8 +-- integration/grpc-web/example.ts | 16 +++--- .../google/protobuf/timestamp.ts | 2 +- integration/import-mapping/mapping.ts | 8 +-- integration/import-suffix/child.pb.ts | 2 +- .../google/protobuf/timestamp.pb.ts | 2 +- integration/import-suffix/parent.pb.ts | 2 +- integration/lower-case-svc-methods/math.ts | 12 ++--- .../meta-typings/google/protobuf/timestamp.ts | 2 +- .../meta-typings/google/protobuf/wrappers.ts | 18 +++---- integration/meta-typings/google/type/date.ts | 2 +- integration/meta-typings/import_dir/thing.ts | 2 +- integration/meta-typings/simple.ts | 48 ++++++++--------- .../nice-grpc/google/protobuf/empty.ts | 2 +- .../nice-grpc/google/protobuf/struct.ts | 8 +-- .../nice-grpc/google/protobuf/timestamp.ts | 2 +- .../nice-grpc/google/protobuf/wrappers.ts | 18 +++---- integration/nice-grpc/simple.ts | 2 +- .../no-proto-package/no-proto-package.ts | 6 +-- integration/omit-optionals/simple.ts | 2 +- integration/oneof-properties/oneof.ts | 4 +- .../google/protobuf/struct.ts | 8 +-- integration/oneof-unions-snake/simple.ts | 2 +- .../oneof-unions/google/protobuf/struct.ts | 8 +-- integration/oneof-unions/oneof.ts | 6 +-- .../options/google/protobuf/descriptor.ts | 54 +++++++++---------- integration/options/options.ts | 8 +-- integration/options/something/something.ts | 2 +- integration/output-decode-only/encode.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- integration/point/point.ts | 4 +- integration/reserved-words/reserved-words.ts | 2 +- integration/return-observable/observable.ts | 4 +- .../simple-deprecated-fields/simple.ts | 4 +- integration/simple-esmodule-interop/simple.ts | 4 +- .../google/protobuf/timestamp.ts | 2 +- integration/simple-json-name/simple.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- integration/simple-long-bigint/simple.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- integration/simple-long-string/simple.ts | 2 +- .../simple-long/google/protobuf/wrappers.ts | 18 +++---- integration/simple-long/simple.ts | 12 ++--- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- .../simple-optionals/import_dir/thing.ts | 2 +- integration/simple-optionals/simple.ts | 36 ++++++------- integration/simple-optionals/thing.ts | 2 +- integration/simple-proto2/simple.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- .../google/type/date.ts | 2 +- .../import_dir/thing.ts | 2 +- .../simple-prototype-defaults/simple.ts | 52 +++++++++--------- .../simple-snake/google/protobuf/struct.ts | 8 +-- .../simple-snake/google/protobuf/timestamp.ts | 2 +- .../simple-snake/google/protobuf/wrappers.ts | 18 +++---- integration/simple-snake/import_dir/thing.ts | 2 +- integration/simple-snake/simple.ts | 38 ++++++------- .../google/protobuf/struct.ts | 8 +-- integration/simple-string-enums/simple.ts | 4 +- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- .../import_dir/thing.ts | 2 +- .../simple-unrecognized-enum/simple.ts | 36 ++++++------- .../simple/google/protobuf/timestamp.ts | 2 +- .../simple/google/protobuf/wrappers.ts | 18 +++---- integration/simple/google/type/date.ts | 2 +- integration/simple/import_dir/thing.ts | 2 +- integration/simple/simple.ts | 52 +++++++++--------- integration/struct/google/protobuf/struct.ts | 8 +-- integration/struct/struct.ts | 2 +- integration/type-registry/bar/bar.ts | 2 +- integration/type-registry/foo.ts | 6 +-- .../type-registry/google/protobuf/struct.ts | 8 +-- .../google/protobuf/timestamp.ts | 2 +- integration/types-with-underscores/file.ts | 4 +- .../google/protobuf/compiler/plugin.ts | 8 +-- .../google/protobuf/descriptor.ts | 54 +++++++++---------- integration/unknown-fields/options.ts | 8 +-- .../unknown-fields/something/something.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- integration/use-date-false/metadata.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../use-date-string/use-date-string.ts | 4 +- .../use-date-true/google/protobuf/empty.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- integration/use-date-true/use-date-true.ts | 6 +-- integration/use-exact-types-false/foo.ts | 2 +- .../use-map-type/google/protobuf/struct.ts | 8 +-- .../use-map-type/google/protobuf/timestamp.ts | 2 +- integration/use-map-type/use-map-type.ts | 14 ++--- .../google/protobuf/struct.ts | 8 +-- integration/use-numeric-enum-json/simple.ts | 4 +- .../objectid/objectid.ts | 2 +- .../use-objectid-true.ts | 4 +- integration/use-optionals-all/test.ts | 6 +-- .../google/protobuf/field_mask.ts | 2 +- .../google/protobuf/struct.ts | 8 +-- .../use-readonly-types/use-readonly-types.ts | 4 +- integration/value/google/protobuf/struct.ts | 8 +-- integration/value/google/protobuf/wrappers.ts | 18 +++---- integration/value/value.ts | 2 +- integration/vector-tile/vector_tile.ts | 8 +-- .../google/protobuf/empty.ts | 2 +- .../google/protobuf/timestamp.ts | 2 +- .../google/protobuf/wrappers.ts | 18 +++---- .../wrappers-regression.ts | 8 +-- src/generate-services.ts | 6 +-- src/main.ts | 2 +- 148 files changed, 605 insertions(+), 605 deletions(-) diff --git a/integration/angular/simple-message.ts b/integration/angular/simple-message.ts index 024daeecf..e01ebf4b9 100644 --- a/integration/angular/simple-message.ts +++ b/integration/angular/simple-message.ts @@ -20,7 +20,7 @@ export const SimpleMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleMessage(); while (reader.pos < end) { diff --git a/integration/async-iterable-services-abort-signal/simple.ts b/integration/async-iterable-services-abort-signal/simple.ts index c35d34e4a..4745e416c 100644 --- a/integration/async-iterable-services-abort-signal/simple.ts +++ b/integration/async-iterable-services-abort-signal/simple.ts @@ -21,7 +21,7 @@ export const EchoMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EchoMsg { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEchoMsg(); while (reader.pos < end) { @@ -117,7 +117,7 @@ export class EchoerClientImpl implements Echoer { Echo(request: EchoMsg, abortSignal?: AbortSignal): Promise { const data = EchoMsg.encode(request).finish(); const promise = this.rpc.request(this.service, "Echo", data, abortSignal || undefined); - return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); + return promise.then((data) => EchoMsg.decode(_m0.Reader.create(data))); } EchoServerStream(request: EchoMsg, abortSignal?: AbortSignal): AsyncIterable { @@ -129,7 +129,7 @@ export class EchoerClientImpl implements Echoer { EchoClientStream(request: AsyncIterable, abortSignal?: AbortSignal): Promise { const data = EchoMsg.encodeTransform(request); const promise = this.rpc.clientStreamingRequest(this.service, "EchoClientStream", data, abortSignal || undefined); - return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); + return promise.then((data) => EchoMsg.decode(_m0.Reader.create(data))); } EchoBidiStream(request: AsyncIterable, abortSignal?: AbortSignal): AsyncIterable { diff --git a/integration/async-iterable-services/simple.ts b/integration/async-iterable-services/simple.ts index f5db589ab..79f54cdb7 100644 --- a/integration/async-iterable-services/simple.ts +++ b/integration/async-iterable-services/simple.ts @@ -21,7 +21,7 @@ export const EchoMsg = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EchoMsg { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEchoMsg(); while (reader.pos < end) { @@ -117,7 +117,7 @@ export class EchoerClientImpl implements Echoer { Echo(request: EchoMsg): Promise { const data = EchoMsg.encode(request).finish(); const promise = this.rpc.request(this.service, "Echo", data); - return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); + return promise.then((data) => EchoMsg.decode(_m0.Reader.create(data))); } EchoServerStream(request: EchoMsg): AsyncIterable { @@ -129,7 +129,7 @@ export class EchoerClientImpl implements Echoer { EchoClientStream(request: AsyncIterable): Promise { const data = EchoMsg.encodeTransform(request); const promise = this.rpc.clientStreamingRequest(this.service, "EchoClientStream", data); - return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); + return promise.then((data) => EchoMsg.decode(_m0.Reader.create(data))); } EchoBidiStream(request: AsyncIterable): AsyncIterable { diff --git a/integration/avoid-import-conflicts/simple.ts b/integration/avoid-import-conflicts/simple.ts index 918901a61..4880fecf1 100644 --- a/integration/avoid-import-conflicts/simple.ts +++ b/integration/avoid-import-conflicts/simple.ts @@ -85,7 +85,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -150,7 +150,7 @@ export const SimpleEnums = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleEnums { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleEnums(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const FooServiceCreateRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FooServiceCreateRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFooServiceCreateRequest(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const FooServiceCreateResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FooServiceCreateResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFooServiceCreateResponse(); while (reader.pos < end) { @@ -313,7 +313,7 @@ export class FooServiceClientImpl implements FooService { Create(request: FooServiceCreateRequest): Promise { const data = FooServiceCreateRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "Create", data); - return promise.then((data) => FooServiceCreateResponse.decode(new _m0.Reader(data))); + return promise.then((data) => FooServiceCreateResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/avoid-import-conflicts/simple2.ts b/integration/avoid-import-conflicts/simple2.ts index 94687d656..65983968d 100644 --- a/integration/avoid-import-conflicts/simple2.ts +++ b/integration/avoid-import-conflicts/simple2.ts @@ -102,7 +102,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { diff --git a/integration/barrel-imports/bar.ts b/integration/barrel-imports/bar.ts index 40c84284a..00784f5c3 100644 --- a/integration/barrel-imports/bar.ts +++ b/integration/barrel-imports/bar.ts @@ -22,7 +22,7 @@ export const Bar = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Bar { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBar(); while (reader.pos < end) { diff --git a/integration/barrel-imports/foo.ts b/integration/barrel-imports/foo.ts index 28a4f4b7a..948fca9c0 100644 --- a/integration/barrel-imports/foo.ts +++ b/integration/barrel-imports/foo.ts @@ -23,7 +23,7 @@ export const Foo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Foo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFoo(); while (reader.pos < end) { diff --git a/integration/batching-with-context/batching.ts b/integration/batching-with-context/batching.ts index 2207cdc4c..370b5e83a 100644 --- a/integration/batching-with-context/batching.ts +++ b/integration/batching-with-context/batching.ts @@ -59,7 +59,7 @@ export const BatchQueryRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchQueryRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchQueryRequest(); while (reader.pos < end) { @@ -114,7 +114,7 @@ export const BatchQueryResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchQueryResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchQueryResponse(); while (reader.pos < end) { @@ -169,7 +169,7 @@ export const BatchMapQueryRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryRequest(); while (reader.pos < end) { @@ -224,7 +224,7 @@ export const BatchMapQueryResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryResponse(); while (reader.pos < end) { @@ -298,7 +298,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryResponse_EntitiesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryResponse_EntitiesEntry(); while (reader.pos < end) { @@ -363,7 +363,7 @@ export const GetOnlyMethodRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GetOnlyMethodRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetOnlyMethodRequest(); while (reader.pos < end) { @@ -414,7 +414,7 @@ export const GetOnlyMethodResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GetOnlyMethodResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetOnlyMethodResponse(); while (reader.pos < end) { @@ -467,7 +467,7 @@ export const WriteMethodRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WriteMethodRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWriteMethodRequest(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const WriteMethodResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WriteMethodResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWriteMethodResponse(); while (reader.pos < end) { @@ -564,7 +564,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -642,7 +642,7 @@ export class EntityServiceClientImpl implements Ent BatchQuery(ctx: Context, request: BatchQueryRequest): Promise { const data = BatchQueryRequest.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "BatchQuery", data); - return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data))); + return promise.then((data) => BatchQueryResponse.decode(_m0.Reader.create(data))); } GetMapQuery(ctx: Context, id: string): Promise { @@ -660,7 +660,7 @@ export class EntityServiceClientImpl implements Ent BatchMapQuery(ctx: Context, request: BatchMapQueryRequest): Promise { const data = BatchMapQueryRequest.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "BatchMapQuery", data); - return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data))); + return promise.then((data) => BatchMapQueryResponse.decode(_m0.Reader.create(data))); } GetOnlyMethod(ctx: Context, request: GetOnlyMethodRequest): Promise { @@ -669,7 +669,7 @@ export class EntityServiceClientImpl implements Ent const responses = requests.map(async (request) => { const data = GetOnlyMethodRequest.encode(request).finish(); const response = await this.rpc.request(ctx, "batching.EntityService", "GetOnlyMethod", data); - return GetOnlyMethodResponse.decode(new _m0.Reader(response)); + return GetOnlyMethodResponse.decode(_m0.Reader.create(response)); }); return Promise.all(responses); }, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions }); @@ -680,7 +680,7 @@ export class EntityServiceClientImpl implements Ent WriteMethod(ctx: Context, request: WriteMethodRequest): Promise { const data = WriteMethodRequest.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "WriteMethod", data); - return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data))); + return promise.then((data) => WriteMethodResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/batching/batching.ts b/integration/batching/batching.ts index a9ba79131..72b8a8666 100644 --- a/integration/batching/batching.ts +++ b/integration/batching/batching.ts @@ -57,7 +57,7 @@ export const BatchQueryRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchQueryRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchQueryRequest(); while (reader.pos < end) { @@ -112,7 +112,7 @@ export const BatchQueryResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchQueryResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchQueryResponse(); while (reader.pos < end) { @@ -167,7 +167,7 @@ export const BatchMapQueryRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryRequest(); while (reader.pos < end) { @@ -222,7 +222,7 @@ export const BatchMapQueryResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryResponse(); while (reader.pos < end) { @@ -296,7 +296,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BatchMapQueryResponse_EntitiesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBatchMapQueryResponse_EntitiesEntry(); while (reader.pos < end) { @@ -361,7 +361,7 @@ export const GetOnlyMethodRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GetOnlyMethodRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetOnlyMethodRequest(); while (reader.pos < end) { @@ -412,7 +412,7 @@ export const GetOnlyMethodResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GetOnlyMethodResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetOnlyMethodResponse(); while (reader.pos < end) { @@ -465,7 +465,7 @@ export const WriteMethodRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WriteMethodRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWriteMethodRequest(); while (reader.pos < end) { @@ -513,7 +513,7 @@ export const WriteMethodResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WriteMethodResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWriteMethodResponse(); while (reader.pos < end) { @@ -562,7 +562,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -628,25 +628,25 @@ export class EntityServiceClientImpl implements EntityService { BatchQuery(request: BatchQueryRequest): Promise { const data = BatchQueryRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "BatchQuery", data); - return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data))); + return promise.then((data) => BatchQueryResponse.decode(_m0.Reader.create(data))); } BatchMapQuery(request: BatchMapQueryRequest): Promise { const data = BatchMapQueryRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "BatchMapQuery", data); - return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data))); + return promise.then((data) => BatchMapQueryResponse.decode(_m0.Reader.create(data))); } GetOnlyMethod(request: GetOnlyMethodRequest): Promise { const data = GetOnlyMethodRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "GetOnlyMethod", data); - return promise.then((data) => GetOnlyMethodResponse.decode(new _m0.Reader(data))); + return promise.then((data) => GetOnlyMethodResponse.decode(_m0.Reader.create(data))); } WriteMethod(request: WriteMethodRequest): Promise { const data = WriteMethodRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "WriteMethod", data); - return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data))); + return promise.then((data) => WriteMethodResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/bytes-node/google/protobuf/wrappers.ts b/integration/bytes-node/google/protobuf/wrappers.ts index 680f4c8ad..9be8348b4 100644 --- a/integration/bytes-node/google/protobuf/wrappers.ts +++ b/integration/bytes-node/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/bytes-node/point.ts b/integration/bytes-node/point.ts index 8067627f4..b55193fb4 100644 --- a/integration/bytes-node/point.ts +++ b/integration/bytes-node/point.ts @@ -25,7 +25,7 @@ export const Point = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Point { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePoint(); while (reader.pos < end) { diff --git a/integration/const-enum/const-enum.ts b/integration/const-enum/const-enum.ts index 189382dc2..b9adf74d4 100644 --- a/integration/const-enum/const-enum.ts +++ b/integration/const-enum/const-enum.ts @@ -90,7 +90,7 @@ export const DividerData = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DividerData { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDividerData(); while (reader.pos < end) { @@ -173,7 +173,7 @@ export const DividerData_TypeMapEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DividerData_TypeMapEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDividerData_TypeMapEntry(); while (reader.pos < end) { diff --git a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts index a76390bb5..fcaffae45 100644 --- a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts +++ b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts @@ -83,7 +83,7 @@ export const DividerData = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DividerData { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDividerData(); while (reader.pos < end) { diff --git a/integration/enums-as-literals/enums-as-literals.ts b/integration/enums-as-literals/enums-as-literals.ts index d5b494284..9d696f037 100644 --- a/integration/enums-as-literals/enums-as-literals.ts +++ b/integration/enums-as-literals/enums-as-literals.ts @@ -61,7 +61,7 @@ export const DividerData = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DividerData { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDividerData(); while (reader.pos < end) { diff --git a/integration/fieldmask/fieldmask.ts b/integration/fieldmask/fieldmask.ts index 7e61d0226..c55421a39 100644 --- a/integration/fieldmask/fieldmask.ts +++ b/integration/fieldmask/fieldmask.ts @@ -21,7 +21,7 @@ export const FieldMaskMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldMaskMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldMaskMessage(); while (reader.pos < end) { diff --git a/integration/fieldmask/google/protobuf/field_mask.ts b/integration/fieldmask/google/protobuf/field_mask.ts index 37ec28306..18a47dbe6 100644 --- a/integration/fieldmask/google/protobuf/field_mask.ts +++ b/integration/fieldmask/google/protobuf/field_mask.ts @@ -221,7 +221,7 @@ export const FieldMask = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldMask { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldMask(); while (reader.pos < end) { diff --git a/integration/file-suffix/child.pb.ts b/integration/file-suffix/child.pb.ts index 4cd5cf613..50e9d8e27 100644 --- a/integration/file-suffix/child.pb.ts +++ b/integration/file-suffix/child.pb.ts @@ -53,7 +53,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { diff --git a/integration/file-suffix/google/protobuf/timestamp.pb.ts b/integration/file-suffix/google/protobuf/timestamp.pb.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/file-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/file-suffix/google/protobuf/timestamp.pb.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/file-suffix/parent.pb.ts b/integration/file-suffix/parent.pb.ts index 0bed45baf..3928b8014 100644 --- a/integration/file-suffix/parent.pb.ts +++ b/integration/file-suffix/parent.pb.ts @@ -30,7 +30,7 @@ export const Parent = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Parent { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseParent(); while (reader.pos < end) { diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index 80923a5c1..418456b7c 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -37,7 +37,7 @@ export const HeroById = { }, decode(input: _m0.Reader | Uint8Array, length?: number): HeroById { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseHeroById(); while (reader.pos < end) { @@ -88,7 +88,7 @@ export const VillainById = { }, decode(input: _m0.Reader | Uint8Array, length?: number): VillainById { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVillainById(); while (reader.pos < end) { @@ -142,7 +142,7 @@ export const Hero = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Hero { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseHero(); while (reader.pos < end) { @@ -201,7 +201,7 @@ export const Villain = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Villain { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVillain(); while (reader.pos < end) { @@ -263,19 +263,19 @@ export class HeroServiceClientImpl implements HeroService { FindOneHero(request: HeroById): Promise { const data = HeroById.encode(request).finish(); const promise = this.rpc.request(this.service, "FindOneHero", data); - return promise.then((data) => Hero.decode(new _m0.Reader(data))); + return promise.then((data) => Hero.decode(_m0.Reader.create(data))); } FindOneVillain(request: VillainById): Promise { const data = VillainById.encode(request).finish(); const promise = this.rpc.request(this.service, "FindOneVillain", data); - return promise.then((data) => Villain.decode(new _m0.Reader(data))); + return promise.then((data) => Villain.decode(_m0.Reader.create(data))); } FindManyVillain(request: Observable): Observable { const data = request.pipe(map((request) => VillainById.encode(request).finish())); const result = this.rpc.bidirectionalStreamingRequest(this.service, "FindManyVillain", data); - return result.pipe(map((data) => Villain.decode(new _m0.Reader(data)))); + return result.pipe(map((data) => Villain.decode(_m0.Reader.create(data)))); } } diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index d1c322674..634cc4c0e 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -20,7 +20,7 @@ export const TestMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TestMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTestMessage(); while (reader.pos < end) { diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index d1c322674..634cc4c0e 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -20,7 +20,7 @@ export const TestMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TestMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTestMessage(); while (reader.pos < end) { diff --git a/integration/global-this/global-this.ts b/integration/global-this/global-this.ts index f9b772596..ab0d8a7cf 100644 --- a/integration/global-this/global-this.ts +++ b/integration/global-this/global-this.ts @@ -24,7 +24,7 @@ export const Object = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Object { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObject(); while (reader.pos < end) { @@ -75,7 +75,7 @@ export const Error = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Error { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseError(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts b/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts index f24a2251f..c2d6bd662 100644 --- a/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts +++ b/integration/grpc-js-use-date-false/grpc-js-use-date-false.ts @@ -33,7 +33,7 @@ export const TimestampMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TimestampMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestampMessage(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts b/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts index 560183fd1..e5b29f41e 100644 --- a/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts +++ b/integration/grpc-js-use-date-string/grpc-js-use-date-string.ts @@ -33,7 +33,7 @@ export const TimestampMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TimestampMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestampMessage(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts b/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts index 2f964a152..6f00a9ef3 100644 --- a/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts +++ b/integration/grpc-js-use-date-true/grpc-js-use-date-true.ts @@ -33,7 +33,7 @@ export const TimestampMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TimestampMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestampMessage(); while (reader.pos < end) { diff --git a/integration/grpc-js/google/protobuf/empty.ts b/integration/grpc-js/google/protobuf/empty.ts index aa4359b94..cbc07ea77 100644 --- a/integration/grpc-js/google/protobuf/empty.ts +++ b/integration/grpc-js/google/protobuf/empty.ts @@ -27,7 +27,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/grpc-js/google/protobuf/struct.ts b/integration/grpc-js/google/protobuf/struct.ts index cc3f1bebd..7307c351c 100644 --- a/integration/grpc-js/google/protobuf/struct.ts +++ b/integration/grpc-js/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/grpc-js/google/protobuf/wrappers.ts b/integration/grpc-js/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/grpc-js/google/protobuf/wrappers.ts +++ b/integration/grpc-js/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/grpc-js/simple.ts b/integration/grpc-js/simple.ts index 35586d3e4..2cd035d37 100644 --- a/integration/grpc-js/simple.ts +++ b/integration/grpc-js/simple.ts @@ -52,7 +52,7 @@ export const TestMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TestMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTestMessage(); while (reader.pos < end) { diff --git a/integration/grpc-web-go-server/example.ts b/integration/grpc-web-go-server/example.ts index bececc87e..8d34325f8 100644 --- a/integration/grpc-web-go-server/example.ts +++ b/integration/grpc-web-go-server/example.ts @@ -109,7 +109,7 @@ export const DashFlash = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashFlash { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashFlash(); while (reader.pos < end) { @@ -174,7 +174,7 @@ export const DashUserSettingsState = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState(); while (reader.pos < end) { @@ -249,7 +249,7 @@ export const DashUserSettingsState_URLs = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState_URLs { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState_URLs(); while (reader.pos < end) { @@ -317,7 +317,7 @@ export const DashCred = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashCred { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashCred(); while (reader.pos < end) { @@ -391,7 +391,7 @@ export const DashAPICredsCreateReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsCreateReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsCreateReq(); while (reader.pos < end) { @@ -459,7 +459,7 @@ export const DashAPICredsUpdateReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsUpdateReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsUpdateReq(); while (reader.pos < end) { @@ -533,7 +533,7 @@ export const DashAPICredsDeleteReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsDeleteReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsDeleteReq(); while (reader.pos < end) { @@ -589,7 +589,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { @@ -639,13 +639,13 @@ export class DashStateClientImpl implements DashState { UserSettings(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "UserSettings", data); - return promise.then((data) => DashUserSettingsState.decode(new _m0.Reader(data))); + return promise.then((data) => DashUserSettingsState.decode(_m0.Reader.create(data))); } ActiveUserSettingsStream(request: Empty): Observable { const data = Empty.encode(request).finish(); const result = this.rpc.serverStreamingRequest(this.service, "ActiveUserSettingsStream", data); - return result.pipe(map((data) => DashUserSettingsState.decode(new _m0.Reader(data)))); + return result.pipe(map((data) => DashUserSettingsState.decode(_m0.Reader.create(data)))); } } @@ -673,19 +673,19 @@ export class DashAPICredsClientImpl implements DashAPICreds { Create(request: DashAPICredsCreateReq): Promise { const data = DashAPICredsCreateReq.encode(request).finish(); const promise = this.rpc.request(this.service, "Create", data); - return promise.then((data) => DashCred.decode(new _m0.Reader(data))); + return promise.then((data) => DashCred.decode(_m0.Reader.create(data))); } Update(request: DashAPICredsUpdateReq): Promise { const data = DashAPICredsUpdateReq.encode(request).finish(); const promise = this.rpc.request(this.service, "Update", data); - return promise.then((data) => DashCred.decode(new _m0.Reader(data))); + return promise.then((data) => DashCred.decode(_m0.Reader.create(data))); } Delete(request: DashAPICredsDeleteReq): Promise { const data = DashAPICredsDeleteReq.encode(request).finish(); const promise = this.rpc.request(this.service, "Delete", data); - return promise.then((data) => DashCred.decode(new _m0.Reader(data))); + return promise.then((data) => DashCred.decode(_m0.Reader.create(data))); } } diff --git a/integration/grpc-web-no-streaming-observable/example.ts b/integration/grpc-web-no-streaming-observable/example.ts index e0e704337..8fa0510a4 100644 --- a/integration/grpc-web-no-streaming-observable/example.ts +++ b/integration/grpc-web-no-streaming-observable/example.ts @@ -87,7 +87,7 @@ export const DashFlash = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashFlash { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashFlash(); while (reader.pos < end) { @@ -152,7 +152,7 @@ export const DashUserSettingsState = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState(); while (reader.pos < end) { @@ -227,7 +227,7 @@ export const DashUserSettingsState_URLs = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState_URLs { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState_URLs(); while (reader.pos < end) { @@ -283,7 +283,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/grpc-web-no-streaming/example.ts b/integration/grpc-web-no-streaming/example.ts index 5ce0f62e0..18e22f050 100644 --- a/integration/grpc-web-no-streaming/example.ts +++ b/integration/grpc-web-no-streaming/example.ts @@ -85,7 +85,7 @@ export const DashFlash = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashFlash { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashFlash(); while (reader.pos < end) { @@ -150,7 +150,7 @@ export const DashUserSettingsState = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState(); while (reader.pos < end) { @@ -225,7 +225,7 @@ export const DashUserSettingsState_URLs = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState_URLs { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState_URLs(); while (reader.pos < end) { @@ -281,7 +281,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/grpc-web/example.ts b/integration/grpc-web/example.ts index 1e7b9fb4b..8e2314ff7 100644 --- a/integration/grpc-web/example.ts +++ b/integration/grpc-web/example.ts @@ -111,7 +111,7 @@ export const DashFlash = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashFlash { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashFlash(); while (reader.pos < end) { @@ -176,7 +176,7 @@ export const DashUserSettingsState = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState(); while (reader.pos < end) { @@ -251,7 +251,7 @@ export const DashUserSettingsState_URLs = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashUserSettingsState_URLs { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashUserSettingsState_URLs(); while (reader.pos < end) { @@ -319,7 +319,7 @@ export const DashCred = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashCred { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashCred(); while (reader.pos < end) { @@ -393,7 +393,7 @@ export const DashAPICredsCreateReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsCreateReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsCreateReq(); while (reader.pos < end) { @@ -461,7 +461,7 @@ export const DashAPICredsUpdateReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsUpdateReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsUpdateReq(); while (reader.pos < end) { @@ -535,7 +535,7 @@ export const DashAPICredsDeleteReq = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DashAPICredsDeleteReq { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDashAPICredsDeleteReq(); while (reader.pos < end) { @@ -591,7 +591,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/import-mapping/google/protobuf/timestamp.ts b/integration/import-mapping/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/import-mapping/google/protobuf/timestamp.ts +++ b/integration/import-mapping/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/import-mapping/mapping.ts b/integration/import-mapping/mapping.ts index a184d1a2d..d7d226ed7 100644 --- a/integration/import-mapping/mapping.ts +++ b/integration/import-mapping/mapping.ts @@ -41,7 +41,7 @@ export const WithEmtpy = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WithEmtpy { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWithEmtpy(); while (reader.pos < end) { @@ -92,7 +92,7 @@ export const WithStruct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WithStruct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWithStruct(); while (reader.pos < end) { @@ -143,7 +143,7 @@ export const WithTimestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WithTimestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWithTimestamp(); while (reader.pos < end) { @@ -206,7 +206,7 @@ export const WithAll = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WithAll { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWithAll(); while (reader.pos < end) { diff --git a/integration/import-suffix/child.pb.ts b/integration/import-suffix/child.pb.ts index 0fd2504cd..6a88f0693 100644 --- a/integration/import-suffix/child.pb.ts +++ b/integration/import-suffix/child.pb.ts @@ -53,7 +53,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { diff --git a/integration/import-suffix/google/protobuf/timestamp.pb.ts b/integration/import-suffix/google/protobuf/timestamp.pb.ts index 98dd46616..c39b2f849 100644 --- a/integration/import-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/import-suffix/google/protobuf/timestamp.pb.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/import-suffix/parent.pb.ts b/integration/import-suffix/parent.pb.ts index 56b399832..2e02381f6 100644 --- a/integration/import-suffix/parent.pb.ts +++ b/integration/import-suffix/parent.pb.ts @@ -30,7 +30,7 @@ export const Parent = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Parent { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseParent(); while (reader.pos < end) { diff --git a/integration/lower-case-svc-methods/math.ts b/integration/lower-case-svc-methods/math.ts index 5a9ca04a5..7f7c45a44 100644 --- a/integration/lower-case-svc-methods/math.ts +++ b/integration/lower-case-svc-methods/math.ts @@ -34,7 +34,7 @@ export const NumPair = { }, decode(input: _m0.Reader | Uint8Array, length?: number): NumPair { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumPair(); while (reader.pos < end) { @@ -90,7 +90,7 @@ export const NumSingle = { }, decode(input: _m0.Reader | Uint8Array, length?: number): NumSingle { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumSingle(); while (reader.pos < end) { @@ -143,7 +143,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -212,13 +212,13 @@ export class MathServiceClientImpl implements MathS add(ctx: Context, request: NumPair): Promise { const data = NumPair.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "Add", data); - return promise.then((data) => NumSingle.decode(new _m0.Reader(data))); + return promise.then((data) => NumSingle.decode(_m0.Reader.create(data))); } absoluteValue(ctx: Context, request: NumSingle): Promise { const data = NumSingle.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "AbsoluteValue", data); - return promise.then((data) => NumSingle.decode(new _m0.Reader(data))); + return promise.then((data) => NumSingle.decode(_m0.Reader.create(data))); } getDouble(ctx: Context, nu: number): Promise { @@ -234,7 +234,7 @@ export class MathServiceClientImpl implements MathS batchDouble(ctx: Context, request: Numbers): Promise { const data = Numbers.encode(request).finish(); const promise = this.rpc.request(ctx, this.service, "BatchDouble", data); - return promise.then((data) => Numbers.decode(new _m0.Reader(data))); + return promise.then((data) => Numbers.decode(_m0.Reader.create(data))); } } diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index 872fdb6f4..3656a7ec8 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -128,7 +128,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/meta-typings/google/protobuf/wrappers.ts b/integration/meta-typings/google/protobuf/wrappers.ts index f57ca984b..1be33c67e 100644 --- a/integration/meta-typings/google/protobuf/wrappers.ts +++ b/integration/meta-typings/google/protobuf/wrappers.ts @@ -108,7 +108,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -139,7 +139,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -170,7 +170,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -201,7 +201,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -232,7 +232,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -263,7 +263,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -294,7 +294,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -325,7 +325,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -356,7 +356,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/meta-typings/google/type/date.ts b/integration/meta-typings/google/type/date.ts index 72e7aceb5..01c6245fc 100644 --- a/integration/meta-typings/google/type/date.ts +++ b/integration/meta-typings/google/type/date.ts @@ -54,7 +54,7 @@ export const DateMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DateMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDateMessage(); while (reader.pos < end) { diff --git a/integration/meta-typings/import_dir/thing.ts b/integration/meta-typings/import_dir/thing.ts index ec843ccd8..17df9050a 100644 --- a/integration/meta-typings/import_dir/thing.ts +++ b/integration/meta-typings/import_dir/thing.ts @@ -22,7 +22,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/meta-typings/simple.ts b/integration/meta-typings/simple.ts index e8cdaef83..f6af40374 100644 --- a/integration/meta-typings/simple.ts +++ b/integration/meta-typings/simple.ts @@ -259,7 +259,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -343,7 +343,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { @@ -383,7 +383,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested(); while (reader.pos < end) { @@ -423,7 +423,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage(); while (reader.pos < end) { @@ -457,7 +457,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage_DeepMessage(); while (reader.pos < end) { @@ -491,7 +491,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfMessage(); while (reader.pos < end) { @@ -537,7 +537,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -580,7 +580,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -623,7 +623,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -684,7 +684,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -721,7 +721,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -758,7 +758,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -795,7 +795,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_MapOfTimestampsEntry(); while (reader.pos < end) { @@ -832,7 +832,7 @@ export const SimpleWithMap_MapOfBytesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfBytesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_MapOfBytesEntry(); while (reader.pos < end) { @@ -866,7 +866,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap(); while (reader.pos < end) { @@ -903,7 +903,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -937,7 +937,7 @@ export const SimpleWithMapOfEnums = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMapOfEnums(); while (reader.pos < end) { @@ -974,7 +974,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums_EnumsByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMapOfEnums_EnumsByIdEntry(); while (reader.pos < end) { @@ -1008,7 +1008,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingRequest(); while (reader.pos < end) { @@ -1039,7 +1039,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingResponse(); while (reader.pos < end) { @@ -1116,7 +1116,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -1206,7 +1206,7 @@ export const SimpleButOptional = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleButOptional { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleButOptional(); while (reader.pos < end) { @@ -1252,7 +1252,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { @@ -1282,7 +1282,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/nice-grpc/google/protobuf/empty.ts b/integration/nice-grpc/google/protobuf/empty.ts index b71279438..a7bb8d3ba 100644 --- a/integration/nice-grpc/google/protobuf/empty.ts +++ b/integration/nice-grpc/google/protobuf/empty.ts @@ -27,7 +27,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/nice-grpc/google/protobuf/struct.ts b/integration/nice-grpc/google/protobuf/struct.ts index 8a5a6a439..f6d1675cc 100644 --- a/integration/nice-grpc/google/protobuf/struct.ts +++ b/integration/nice-grpc/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/nice-grpc/google/protobuf/timestamp.ts b/integration/nice-grpc/google/protobuf/timestamp.ts index f0fa36cf5..14f5f6d88 100644 --- a/integration/nice-grpc/google/protobuf/timestamp.ts +++ b/integration/nice-grpc/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/nice-grpc/google/protobuf/wrappers.ts b/integration/nice-grpc/google/protobuf/wrappers.ts index 93d4981eb..72a40ff73 100644 --- a/integration/nice-grpc/google/protobuf/wrappers.ts +++ b/integration/nice-grpc/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index a9fb0873c..a8bba4748 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -35,7 +35,7 @@ export const TestMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TestMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTestMessage(); while (reader.pos < end) { diff --git a/integration/no-proto-package/no-proto-package.ts b/integration/no-proto-package/no-proto-package.ts index 753dcf0bb..1e2fef379 100644 --- a/integration/no-proto-package/no-proto-package.ts +++ b/integration/no-proto-package/no-proto-package.ts @@ -25,7 +25,7 @@ export const User = { }, decode(input: _m0.Reader | Uint8Array, length?: number): User { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUser(); while (reader.pos < end) { @@ -73,7 +73,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { @@ -121,7 +121,7 @@ export class UserStateClientImpl implements UserState { GetUsers(request: Empty): Observable { const data = Empty.encode(request).finish(); const result = this.rpc.serverStreamingRequest(this.service, "GetUsers", data); - return result.pipe(map((data) => User.decode(new _m0.Reader(data)))); + return result.pipe(map((data) => User.decode(_m0.Reader.create(data)))); } } diff --git a/integration/omit-optionals/simple.ts b/integration/omit-optionals/simple.ts index fb421eeac..79788934e 100644 --- a/integration/omit-optionals/simple.ts +++ b/integration/omit-optionals/simple.ts @@ -24,7 +24,7 @@ export const TestMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): TestMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTestMessage(); while (reader.pos < end) { diff --git a/integration/oneof-properties/oneof.ts b/integration/oneof-properties/oneof.ts index 5e707c715..5278b408c 100644 --- a/integration/oneof-properties/oneof.ts +++ b/integration/oneof-properties/oneof.ts @@ -131,7 +131,7 @@ export const PleaseChoose = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PleaseChoose { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePleaseChoose(); while (reader.pos < end) { @@ -249,7 +249,7 @@ export const PleaseChoose_Submessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PleaseChoose_Submessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePleaseChoose_Submessage(); while (reader.pos < end) { diff --git a/integration/oneof-unions-snake/google/protobuf/struct.ts b/integration/oneof-unions-snake/google/protobuf/struct.ts index 14a1efa4f..47b7e5a71 100644 --- a/integration/oneof-unions-snake/google/protobuf/struct.ts +++ b/integration/oneof-unions-snake/google/protobuf/struct.ts @@ -100,7 +100,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -197,7 +197,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -270,7 +270,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -432,7 +432,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/oneof-unions-snake/simple.ts b/integration/oneof-unions-snake/simple.ts index 77b6760a9..49a4c7e58 100644 --- a/integration/oneof-unions-snake/simple.ts +++ b/integration/oneof-unions-snake/simple.ts @@ -26,7 +26,7 @@ export const SimpleStruct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleStruct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleStruct(); while (reader.pos < end) { diff --git a/integration/oneof-unions/google/protobuf/struct.ts b/integration/oneof-unions/google/protobuf/struct.ts index e86599eee..50af5ea9a 100644 --- a/integration/oneof-unions/google/protobuf/struct.ts +++ b/integration/oneof-unions/google/protobuf/struct.ts @@ -100,7 +100,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -197,7 +197,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -270,7 +270,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -423,7 +423,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/oneof-unions/oneof.ts b/integration/oneof-unions/oneof.ts index c48473ad7..45f63c815 100644 --- a/integration/oneof-unions/oneof.ts +++ b/integration/oneof-unions/oneof.ts @@ -124,7 +124,7 @@ export const PleaseChoose = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PleaseChoose { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePleaseChoose(); while (reader.pos < end) { @@ -296,7 +296,7 @@ export const PleaseChoose_Submessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PleaseChoose_Submessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePleaseChoose_Submessage(); while (reader.pos < end) { @@ -350,7 +350,7 @@ export const SimpleButOptional = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleButOptional { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleButOptional(); while (reader.pos < end) { diff --git a/integration/options/google/protobuf/descriptor.ts b/integration/options/google/protobuf/descriptor.ts index 6469a46d9..c0d012262 100644 --- a/integration/options/google/protobuf/descriptor.ts +++ b/integration/options/google/protobuf/descriptor.ts @@ -874,7 +874,7 @@ export const FileDescriptorSet = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileDescriptorSet { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileDescriptorSet(); while (reader.pos < end) { @@ -955,7 +955,7 @@ export const FileDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileDescriptorProto(); while (reader.pos < end) { @@ -1071,7 +1071,7 @@ export const DescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto(); while (reader.pos < end) { @@ -1135,7 +1135,7 @@ export const DescriptorProto_ExtensionRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto_ExtensionRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto_ExtensionRange(); while (reader.pos < end) { @@ -1175,7 +1175,7 @@ export const DescriptorProto_ReservedRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto_ReservedRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto_ReservedRange(); while (reader.pos < end) { @@ -1209,7 +1209,7 @@ export const ExtensionRangeOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ExtensionRangeOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseExtensionRangeOptions(); while (reader.pos < end) { @@ -1282,7 +1282,7 @@ export const FieldDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldDescriptorProto(); while (reader.pos < end) { @@ -1346,7 +1346,7 @@ export const OneofDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneofDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneofDescriptorProto(); while (reader.pos < end) { @@ -1392,7 +1392,7 @@ export const EnumDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumDescriptorProto(); while (reader.pos < end) { @@ -1438,7 +1438,7 @@ export const EnumDescriptorProto_EnumReservedRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumDescriptorProto_EnumReservedRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumDescriptorProto_EnumReservedRange(); while (reader.pos < end) { @@ -1478,7 +1478,7 @@ export const EnumValueDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumValueDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumValueDescriptorProto(); while (reader.pos < end) { @@ -1521,7 +1521,7 @@ export const ServiceDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ServiceDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseServiceDescriptorProto(); while (reader.pos < end) { @@ -1580,7 +1580,7 @@ export const MethodDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MethodDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMethodDescriptorProto(); while (reader.pos < end) { @@ -1708,7 +1708,7 @@ export const FileOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileOptions(); while (reader.pos < end) { @@ -1817,7 +1817,7 @@ export const MessageOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MessageOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMessageOptions(); while (reader.pos < end) { @@ -1878,7 +1878,7 @@ export const FieldOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldOptions(); while (reader.pos < end) { @@ -1927,7 +1927,7 @@ export const OneofOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneofOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneofOptions(); while (reader.pos < end) { @@ -1964,7 +1964,7 @@ export const EnumOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumOptions(); while (reader.pos < end) { @@ -2004,7 +2004,7 @@ export const EnumValueOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumValueOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumValueOptions(); while (reader.pos < end) { @@ -2041,7 +2041,7 @@ export const ServiceOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ServiceOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseServiceOptions(); while (reader.pos < end) { @@ -2081,7 +2081,7 @@ export const MethodOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MethodOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMethodOptions(); while (reader.pos < end) { @@ -2144,7 +2144,7 @@ export const UninterpretedOption = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UninterpretedOption { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUninterpretedOption(); while (reader.pos < end) { @@ -2196,7 +2196,7 @@ export const UninterpretedOption_NamePart = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UninterpretedOption_NamePart { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUninterpretedOption_NamePart(); while (reader.pos < end) { @@ -2230,7 +2230,7 @@ export const SourceCodeInfo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SourceCodeInfo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSourceCodeInfo(); while (reader.pos < end) { @@ -2277,7 +2277,7 @@ export const SourceCodeInfo_Location = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SourceCodeInfo_Location { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSourceCodeInfo_Location(); while (reader.pos < end) { @@ -2334,7 +2334,7 @@ export const GeneratedCodeInfo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GeneratedCodeInfo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGeneratedCodeInfo(); while (reader.pos < end) { @@ -2376,7 +2376,7 @@ export const GeneratedCodeInfo_Annotation = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GeneratedCodeInfo_Annotation { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGeneratedCodeInfo_Annotation(); while (reader.pos < end) { diff --git a/integration/options/options.ts b/integration/options/options.ts index f0b907540..c21d07eb3 100644 --- a/integration/options/options.ts +++ b/integration/options/options.ts @@ -47,7 +47,7 @@ export const MyMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MyMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMyMessage(); while (reader.pos < end) { @@ -84,7 +84,7 @@ export const RequestType = { }, decode(input: _m0.Reader | Uint8Array, length?: number): RequestType { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRequestType(); while (reader.pos < end) { @@ -109,7 +109,7 @@ export const ResponseType = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ResponseType { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseResponseType(); while (reader.pos < end) { @@ -139,7 +139,7 @@ export class MyServiceClientImpl implements MyService { MyMethod(request: RequestType): Promise { const data = RequestType.encode(request).finish(); const promise = this.rpc.request(this.service, "MyMethod", data); - return promise.then((data) => ResponseType.decode(new _m0.Reader(data))); + return promise.then((data) => ResponseType.decode(_m0.Reader.create(data))); } } diff --git a/integration/options/something/something.ts b/integration/options/something/something.ts index 7fb1154f3..b0d49215e 100644 --- a/integration/options/something/something.ts +++ b/integration/options/something/something.ts @@ -28,7 +28,7 @@ export const Something = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Something { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSomething(); while (reader.pos < end) { diff --git a/integration/output-decode-only/encode.ts b/integration/output-decode-only/encode.ts index 31b0351a6..b2d0f56c2 100644 --- a/integration/output-decode-only/encode.ts +++ b/integration/output-decode-only/encode.ts @@ -13,7 +13,7 @@ function createBaseEncode(): Encode { export const Encode = { decode(input: _m0.Reader | Uint8Array, length?: number): Encode { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEncode(); while (reader.pos < end) { diff --git a/integration/output-decode-only/google/protobuf/wrappers.ts b/integration/output-decode-only/google/protobuf/wrappers.ts index c25da7f81..d28164cad 100644 --- a/integration/output-decode-only/google/protobuf/wrappers.ts +++ b/integration/output-decode-only/google/protobuf/wrappers.ts @@ -100,7 +100,7 @@ function createBaseDoubleValue(): DoubleValue { export const DoubleValue = { decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -124,7 +124,7 @@ function createBaseFloatValue(): FloatValue { export const FloatValue = { decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -148,7 +148,7 @@ function createBaseInt64Value(): Int64Value { export const Int64Value = { decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -172,7 +172,7 @@ function createBaseUInt64Value(): UInt64Value { export const UInt64Value = { decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -196,7 +196,7 @@ function createBaseInt32Value(): Int32Value { export const Int32Value = { decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -220,7 +220,7 @@ function createBaseUInt32Value(): UInt32Value { export const UInt32Value = { decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -244,7 +244,7 @@ function createBaseBoolValue(): BoolValue { export const BoolValue = { decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -268,7 +268,7 @@ function createBaseStringValue(): StringValue { export const StringValue = { decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -292,7 +292,7 @@ function createBaseBytesValue(): BytesValue { export const BytesValue = { decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/point/point.ts b/integration/point/point.ts index 2cfa98809..45a1abdaa 100644 --- a/integration/point/point.ts +++ b/integration/point/point.ts @@ -29,7 +29,7 @@ export const Point = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Point { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePoint(); while (reader.pos < end) { @@ -88,7 +88,7 @@ export const Area = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Area { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseArea(); while (reader.pos < end) { diff --git a/integration/reserved-words/reserved-words.ts b/integration/reserved-words/reserved-words.ts index 114c97a6c..58ce48546 100644 --- a/integration/reserved-words/reserved-words.ts +++ b/integration/reserved-words/reserved-words.ts @@ -16,7 +16,7 @@ export const Record = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Record { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRecord(); while (reader.pos < end) { diff --git a/integration/return-observable/observable.ts b/integration/return-observable/observable.ts index 26ae460db..0071b1176 100644 --- a/integration/return-observable/observable.ts +++ b/integration/return-observable/observable.ts @@ -25,7 +25,7 @@ export const ProduceRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ProduceRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseProduceRequest(); while (reader.pos < end) { @@ -76,7 +76,7 @@ export const ProduceReply = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ProduceReply { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseProduceReply(); while (reader.pos < end) { diff --git a/integration/simple-deprecated-fields/simple.ts b/integration/simple-deprecated-fields/simple.ts index 4a5875ef8..cb63a8397 100644 --- a/integration/simple-deprecated-fields/simple.ts +++ b/integration/simple-deprecated-fields/simple.ts @@ -58,7 +58,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -135,7 +135,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { diff --git a/integration/simple-esmodule-interop/simple.ts b/integration/simple-esmodule-interop/simple.ts index e723012eb..770a621f0 100644 --- a/integration/simple-esmodule-interop/simple.ts +++ b/integration/simple-esmodule-interop/simple.ts @@ -40,7 +40,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -142,7 +142,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { diff --git a/integration/simple-json-name/google/protobuf/timestamp.ts b/integration/simple-json-name/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/simple-json-name/google/protobuf/timestamp.ts +++ b/integration/simple-json-name/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-json-name/simple.ts b/integration/simple-json-name/simple.ts index c4eb1b5c7..c7d20720f 100644 --- a/integration/simple-json-name/simple.ts +++ b/integration/simple-json-name/simple.ts @@ -58,7 +58,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { diff --git a/integration/simple-long-bigint/google/protobuf/timestamp.ts b/integration/simple-long-bigint/google/protobuf/timestamp.ts index 054ee07e9..b07e5dfb0 100644 --- a/integration/simple-long-bigint/google/protobuf/timestamp.ts +++ b/integration/simple-long-bigint/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-long-bigint/google/protobuf/wrappers.ts b/integration/simple-long-bigint/google/protobuf/wrappers.ts index 1bdfa04a0..48715d734 100644 --- a/integration/simple-long-bigint/google/protobuf/wrappers.ts +++ b/integration/simple-long-bigint/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-long-bigint/simple.ts b/integration/simple-long-bigint/simple.ts index 254001f0c..a49b3ed3f 100644 --- a/integration/simple-long-bigint/simple.ts +++ b/integration/simple-long-bigint/simple.ts @@ -97,7 +97,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { diff --git a/integration/simple-long-string/google/protobuf/timestamp.ts b/integration/simple-long-string/google/protobuf/timestamp.ts index 3778636b8..2c955616e 100644 --- a/integration/simple-long-string/google/protobuf/timestamp.ts +++ b/integration/simple-long-string/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-long-string/google/protobuf/wrappers.ts b/integration/simple-long-string/google/protobuf/wrappers.ts index 7df87905c..5f5864746 100644 --- a/integration/simple-long-string/google/protobuf/wrappers.ts +++ b/integration/simple-long-string/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-long-string/simple.ts b/integration/simple-long-string/simple.ts index 3eda06fdd..121626abe 100644 --- a/integration/simple-long-string/simple.ts +++ b/integration/simple-long-string/simple.ts @@ -90,7 +90,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { diff --git a/integration/simple-long/google/protobuf/wrappers.ts b/integration/simple-long/google/protobuf/wrappers.ts index 8bdd22fe6..276a821d1 100644 --- a/integration/simple-long/google/protobuf/wrappers.ts +++ b/integration/simple-long/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index 99a6474f4..80ad248e5 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -81,7 +81,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -180,7 +180,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -372,7 +372,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -431,7 +431,7 @@ export const SimpleWithMap_LongLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_LongLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_LongLookupEntry(); while (reader.pos < end) { @@ -544,7 +544,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { diff --git a/integration/simple-optionals/google/protobuf/timestamp.ts b/integration/simple-optionals/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/simple-optionals/google/protobuf/timestamp.ts +++ b/integration/simple-optionals/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-optionals/google/protobuf/wrappers.ts b/integration/simple-optionals/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/simple-optionals/google/protobuf/wrappers.ts +++ b/integration/simple-optionals/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-optionals/import_dir/thing.ts b/integration/simple-optionals/import_dir/thing.ts index 641cef592..7ff94bb95 100644 --- a/integration/simple-optionals/import_dir/thing.ts +++ b/integration/simple-optionals/import_dir/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/simple-optionals/simple.ts b/integration/simple-optionals/simple.ts index 3d256d968..cb5e80064 100644 --- a/integration/simple-optionals/simple.ts +++ b/integration/simple-optionals/simple.ts @@ -293,7 +293,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -437,7 +437,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { @@ -502,7 +502,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested(); while (reader.pos < end) { @@ -573,7 +573,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage(); while (reader.pos < end) { @@ -635,7 +635,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage_DeepMessage(); while (reader.pos < end) { @@ -691,7 +691,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfMessage(); while (reader.pos < end) { @@ -762,7 +762,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -847,7 +847,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -904,7 +904,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -1035,7 +1035,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1101,7 +1101,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -1162,7 +1162,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -1218,7 +1218,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap(); while (reader.pos < end) { @@ -1295,7 +1295,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1360,7 +1360,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingRequest(); while (reader.pos < end) { @@ -1411,7 +1411,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingResponse(); while (reader.pos < end) { @@ -1508,7 +1508,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -1629,7 +1629,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/simple-optionals/thing.ts b/integration/simple-optionals/thing.ts index 89923ce35..abf160624 100644 --- a/integration/simple-optionals/thing.ts +++ b/integration/simple-optionals/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/simple-proto2/simple.ts b/integration/simple-proto2/simple.ts index 0d280f797..08ff0665a 100644 --- a/integration/simple-proto2/simple.ts +++ b/integration/simple-proto2/simple.ts @@ -53,7 +53,7 @@ export const Issue56 = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Issue56 { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseIssue56(); while (reader.pos < end) { diff --git a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts index 6978be6b9..a77360c68 100644 --- a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts +++ b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseTimestamp()) as Timestamp; while (reader.pos < end) { diff --git a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts index 20e5af649..b3031cb05 100644 --- a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts +++ b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseDoubleValue()) as DoubleValue; while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseFloatValue()) as FloatValue; while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseInt64Value()) as Int64Value; while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseUInt64Value()) as UInt64Value; while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseInt32Value()) as Int32Value; while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseUInt32Value()) as UInt32Value; while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseBoolValue()) as BoolValue; while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseStringValue()) as StringValue; while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseBytesValue()) as BytesValue; while (reader.pos < end) { diff --git a/integration/simple-prototype-defaults/google/type/date.ts b/integration/simple-prototype-defaults/google/type/date.ts index 02658fb80..e5004fce4 100644 --- a/integration/simple-prototype-defaults/google/type/date.ts +++ b/integration/simple-prototype-defaults/google/type/date.ts @@ -53,7 +53,7 @@ export const DateMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DateMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseDateMessage()) as DateMessage; while (reader.pos < end) { diff --git a/integration/simple-prototype-defaults/import_dir/thing.ts b/integration/simple-prototype-defaults/import_dir/thing.ts index 04ed9afcf..b9724bd0c 100644 --- a/integration/simple-prototype-defaults/import_dir/thing.ts +++ b/integration/simple-prototype-defaults/import_dir/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseImportedThing()) as ImportedThing; while (reader.pos < end) { diff --git a/integration/simple-prototype-defaults/simple.ts b/integration/simple-prototype-defaults/simple.ts index 55424b954..5420073ff 100644 --- a/integration/simple-prototype-defaults/simple.ts +++ b/integration/simple-prototype-defaults/simple.ts @@ -367,7 +367,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimple()) as Simple; while (reader.pos < end) { @@ -537,7 +537,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseChild()) as Child; while (reader.pos < end) { @@ -602,7 +602,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseNested()) as Nested; while (reader.pos < end) { @@ -673,7 +673,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseNested_InnerMessage()) as Nested_InnerMessage; while (reader.pos < end) { @@ -735,7 +735,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseNested_InnerMessage_DeepMessage()) as Nested_InnerMessage_DeepMessage; while (reader.pos < end) { @@ -791,7 +791,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseOneOfMessage()) as OneOfMessage; while (reader.pos < end) { @@ -865,7 +865,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithWrappers()) as SimpleWithWrappers; while (reader.pos < end) { @@ -956,7 +956,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseEntity()) as Entity; while (reader.pos < end) { @@ -1035,7 +1035,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap()) as SimpleWithMap; while (reader.pos < end) { @@ -1276,7 +1276,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_EntitiesByIdEntry()) as SimpleWithMap_EntitiesByIdEntry; while (reader.pos < end) { @@ -1342,7 +1342,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_NameLookupEntry()) as SimpleWithMap_NameLookupEntry; while (reader.pos < end) { @@ -1403,7 +1403,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_IntLookupEntry()) as SimpleWithMap_IntLookupEntry; while (reader.pos < end) { @@ -1462,7 +1462,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_MapOfTimestampsEntry()) as SimpleWithMap_MapOfTimestampsEntry; while (reader.pos < end) { @@ -1528,7 +1528,7 @@ export const SimpleWithMap_MapOfBytesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfBytesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_MapOfBytesEntry()) as SimpleWithMap_MapOfBytesEntry; while (reader.pos < end) { @@ -1593,7 +1593,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfStringValuesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( createBaseSimpleWithMap_MapOfStringValuesEntry(), @@ -1663,7 +1663,7 @@ export const SimpleWithMap_LongLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_LongLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMap_LongLookupEntry()) as SimpleWithMap_LongLookupEntry; while (reader.pos < end) { @@ -1721,7 +1721,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithSnakeCaseMap()) as SimpleWithSnakeCaseMap; while (reader.pos < end) { @@ -1798,7 +1798,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(), @@ -1867,7 +1867,7 @@ export const SimpleWithMapOfEnums = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleWithMapOfEnums()) as SimpleWithMapOfEnums; while (reader.pos < end) { @@ -1944,7 +1944,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums_EnumsByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( createBaseSimpleWithMapOfEnums_EnumsByIdEntry(), @@ -2011,7 +2011,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBasePingRequest()) as PingRequest; while (reader.pos < end) { @@ -2062,7 +2062,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBasePingResponse()) as PingResponse; while (reader.pos < end) { @@ -2159,7 +2159,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseNumbers()) as Numbers; while (reader.pos < end) { @@ -2304,7 +2304,7 @@ export const SimpleButOptional = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleButOptional { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseSimpleButOptional()) as SimpleButOptional; while (reader.pos < end) { @@ -2396,7 +2396,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create(createBaseEmpty()) as Empty; while (reader.pos < end) { @@ -2444,7 +2444,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/simple-snake/google/protobuf/struct.ts b/integration/simple-snake/google/protobuf/struct.ts index 4dbdbd8a4..7798e7e51 100644 --- a/integration/simple-snake/google/protobuf/struct.ts +++ b/integration/simple-snake/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/simple-snake/google/protobuf/timestamp.ts b/integration/simple-snake/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/simple-snake/google/protobuf/timestamp.ts +++ b/integration/simple-snake/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-snake/google/protobuf/wrappers.ts b/integration/simple-snake/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/simple-snake/google/protobuf/wrappers.ts +++ b/integration/simple-snake/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-snake/import_dir/thing.ts b/integration/simple-snake/import_dir/thing.ts index 938a980d8..b1357f51b 100644 --- a/integration/simple-snake/import_dir/thing.ts +++ b/integration/simple-snake/import_dir/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/simple-snake/simple.ts b/integration/simple-snake/simple.ts index 31a498425..ae860a031 100644 --- a/integration/simple-snake/simple.ts +++ b/integration/simple-snake/simple.ts @@ -298,7 +298,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -442,7 +442,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { @@ -507,7 +507,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested(); while (reader.pos < end) { @@ -578,7 +578,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage(); while (reader.pos < end) { @@ -640,7 +640,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage_DeepMessage(); while (reader.pos < end) { @@ -696,7 +696,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfMessage(); while (reader.pos < end) { @@ -767,7 +767,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -852,7 +852,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -909,7 +909,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -1040,7 +1040,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1106,7 +1106,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -1167,7 +1167,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -1223,7 +1223,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap(); while (reader.pos < end) { @@ -1300,7 +1300,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1365,7 +1365,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingRequest(); while (reader.pos < end) { @@ -1416,7 +1416,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingResponse(); while (reader.pos < end) { @@ -1513,7 +1513,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -1632,7 +1632,7 @@ export const SimpleStruct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleStruct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleStruct(); while (reader.pos < end) { @@ -1685,7 +1685,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/simple-string-enums/google/protobuf/struct.ts b/integration/simple-string-enums/google/protobuf/struct.ts index 09cb4ca9b..7467b4700 100644 --- a/integration/simple-string-enums/google/protobuf/struct.ts +++ b/integration/simple-string-enums/google/protobuf/struct.ts @@ -125,7 +125,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -222,7 +222,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -300,7 +300,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -421,7 +421,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/simple-string-enums/simple.ts b/integration/simple-string-enums/simple.ts index ad1e8933d..4ac673b42 100644 --- a/integration/simple-string-enums/simple.ts +++ b/integration/simple-string-enums/simple.ts @@ -97,7 +97,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Simple_StateMapEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple_StateMapEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple_StateMapEntry(); while (reader.pos < end) { diff --git a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple-unrecognized-enum/import_dir/thing.ts b/integration/simple-unrecognized-enum/import_dir/thing.ts index d97d4521d..987d1d13c 100644 --- a/integration/simple-unrecognized-enum/import_dir/thing.ts +++ b/integration/simple-unrecognized-enum/import_dir/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/simple-unrecognized-enum/simple.ts b/integration/simple-unrecognized-enum/simple.ts index cd0df9442..0acd77e68 100644 --- a/integration/simple-unrecognized-enum/simple.ts +++ b/integration/simple-unrecognized-enum/simple.ts @@ -281,7 +281,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -425,7 +425,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { @@ -490,7 +490,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested(); while (reader.pos < end) { @@ -561,7 +561,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage(); while (reader.pos < end) { @@ -623,7 +623,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage_DeepMessage(); while (reader.pos < end) { @@ -679,7 +679,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfMessage(); while (reader.pos < end) { @@ -750,7 +750,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -835,7 +835,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -892,7 +892,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -1023,7 +1023,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1089,7 +1089,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -1150,7 +1150,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -1206,7 +1206,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap(); while (reader.pos < end) { @@ -1283,7 +1283,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1348,7 +1348,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingRequest(); while (reader.pos < end) { @@ -1399,7 +1399,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingResponse(); while (reader.pos < end) { @@ -1496,7 +1496,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -1617,7 +1617,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/simple/google/protobuf/wrappers.ts b/integration/simple/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/simple/google/protobuf/wrappers.ts +++ b/integration/simple/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/simple/google/type/date.ts b/integration/simple/google/type/date.ts index 4a8efca31..23f4702d4 100644 --- a/integration/simple/google/type/date.ts +++ b/integration/simple/google/type/date.ts @@ -53,7 +53,7 @@ export const DateMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DateMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDateMessage(); while (reader.pos < end) { diff --git a/integration/simple/import_dir/thing.ts b/integration/simple/import_dir/thing.ts index d97d4521d..987d1d13c 100644 --- a/integration/simple/import_dir/thing.ts +++ b/integration/simple/import_dir/thing.ts @@ -21,7 +21,7 @@ export const ImportedThing = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ImportedThing { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseImportedThing(); while (reader.pos < end) { diff --git a/integration/simple/simple.ts b/integration/simple/simple.ts index 96f2df349..7954752da 100644 --- a/integration/simple/simple.ts +++ b/integration/simple/simple.ts @@ -372,7 +372,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -548,7 +548,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { @@ -613,7 +613,7 @@ export const Nested = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested(); while (reader.pos < end) { @@ -684,7 +684,7 @@ export const Nested_InnerMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage(); while (reader.pos < end) { @@ -746,7 +746,7 @@ export const Nested_InnerMessage_DeepMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Nested_InnerMessage_DeepMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNested_InnerMessage_DeepMessage(); while (reader.pos < end) { @@ -802,7 +802,7 @@ export const OneOfMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneOfMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfMessage(); while (reader.pos < end) { @@ -876,7 +876,7 @@ export const SimpleWithWrappers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithWrappers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithWrappers(); while (reader.pos < end) { @@ -967,7 +967,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -1046,7 +1046,7 @@ export const SimpleWithMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap(); while (reader.pos < end) { @@ -1287,7 +1287,7 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1353,7 +1353,7 @@ export const SimpleWithMap_NameLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_NameLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_NameLookupEntry(); while (reader.pos < end) { @@ -1414,7 +1414,7 @@ export const SimpleWithMap_IntLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_IntLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_IntLookupEntry(); while (reader.pos < end) { @@ -1473,7 +1473,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_MapOfTimestampsEntry(); while (reader.pos < end) { @@ -1539,7 +1539,7 @@ export const SimpleWithMap_MapOfBytesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfBytesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_MapOfBytesEntry(); while (reader.pos < end) { @@ -1604,7 +1604,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_MapOfStringValuesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_MapOfStringValuesEntry(); while (reader.pos < end) { @@ -1670,7 +1670,7 @@ export const SimpleWithMap_LongLookupEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMap_LongLookupEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMap_LongLookupEntry(); while (reader.pos < end) { @@ -1728,7 +1728,7 @@ export const SimpleWithSnakeCaseMap = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap(); while (reader.pos < end) { @@ -1805,7 +1805,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithSnakeCaseMap_EntitiesByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); while (reader.pos < end) { @@ -1870,7 +1870,7 @@ export const SimpleWithMapOfEnums = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMapOfEnums(); while (reader.pos < end) { @@ -1947,7 +1947,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleWithMapOfEnums_EnumsByIdEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleWithMapOfEnums_EnumsByIdEntry(); while (reader.pos < end) { @@ -2010,7 +2010,7 @@ export const PingRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingRequest(); while (reader.pos < end) { @@ -2061,7 +2061,7 @@ export const PingResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): PingResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePingResponse(); while (reader.pos < end) { @@ -2158,7 +2158,7 @@ export const Numbers = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Numbers { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseNumbers(); while (reader.pos < end) { @@ -2303,7 +2303,7 @@ export const SimpleButOptional = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SimpleButOptional { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimpleButOptional(); while (reader.pos < end) { @@ -2395,7 +2395,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { @@ -2443,7 +2443,7 @@ export class PingServiceClientImpl implements PingService { ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ping", data); - return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); + return promise.then((data) => PingResponse.decode(_m0.Reader.create(data))); } } diff --git a/integration/struct/google/protobuf/struct.ts b/integration/struct/google/protobuf/struct.ts index cc3f1bebd..7307c351c 100644 --- a/integration/struct/google/protobuf/struct.ts +++ b/integration/struct/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/struct/struct.ts b/integration/struct/struct.ts index 2384c5c5b..b597cec19 100644 --- a/integration/struct/struct.ts +++ b/integration/struct/struct.ts @@ -21,7 +21,7 @@ export const StructMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StructMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStructMessage(); while (reader.pos < end) { diff --git a/integration/type-registry/bar/bar.ts b/integration/type-registry/bar/bar.ts index b93b23996..c14588dca 100644 --- a/integration/type-registry/bar/bar.ts +++ b/integration/type-registry/bar/bar.ts @@ -25,7 +25,7 @@ export const Bar = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Bar { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBar(); while (reader.pos < end) { diff --git a/integration/type-registry/foo.ts b/integration/type-registry/foo.ts index 388956209..14c48d549 100644 --- a/integration/type-registry/foo.ts +++ b/integration/type-registry/foo.ts @@ -36,7 +36,7 @@ export const Foo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Foo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFoo(); while (reader.pos < end) { @@ -91,7 +91,7 @@ export const Foo2 = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Foo2 { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFoo2(); while (reader.pos < end) { @@ -146,7 +146,7 @@ export const WithStruct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): WithStruct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseWithStruct(); while (reader.pos < end) { diff --git a/integration/type-registry/google/protobuf/struct.ts b/integration/type-registry/google/protobuf/struct.ts index 4eb87ba66..c6873fe86 100644 --- a/integration/type-registry/google/protobuf/struct.ts +++ b/integration/type-registry/google/protobuf/struct.ts @@ -125,7 +125,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -227,7 +227,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -314,7 +314,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -440,7 +440,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index c85054eae..a160eb926 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -131,7 +131,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/types-with-underscores/file.ts b/integration/types-with-underscores/file.ts index 729efc0e6..41c9f4d4d 100644 --- a/integration/types-with-underscores/file.ts +++ b/integration/types-with-underscores/file.ts @@ -23,7 +23,7 @@ export const Baz = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Baz { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBaz(); while (reader.pos < end) { @@ -71,7 +71,7 @@ export const FooBar = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FooBar { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFooBar(); while (reader.pos < end) { diff --git a/integration/unknown-fields/google/protobuf/compiler/plugin.ts b/integration/unknown-fields/google/protobuf/compiler/plugin.ts index 21528d58c..364c81e48 100644 --- a/integration/unknown-fields/google/protobuf/compiler/plugin.ts +++ b/integration/unknown-fields/google/protobuf/compiler/plugin.ts @@ -178,7 +178,7 @@ export const Version = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Version { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVersion(); (message as any)._unknownFields = {}; @@ -247,7 +247,7 @@ export const CodeGeneratorRequest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): CodeGeneratorRequest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCodeGeneratorRequest(); (message as any)._unknownFields = {}; @@ -313,7 +313,7 @@ export const CodeGeneratorResponse = { }, decode(input: _m0.Reader | Uint8Array, length?: number): CodeGeneratorResponse { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCodeGeneratorResponse(); (message as any)._unknownFields = {}; @@ -379,7 +379,7 @@ export const CodeGeneratorResponse_File = { }, decode(input: _m0.Reader | Uint8Array, length?: number): CodeGeneratorResponse_File { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCodeGeneratorResponse_File(); (message as any)._unknownFields = {}; diff --git a/integration/unknown-fields/google/protobuf/descriptor.ts b/integration/unknown-fields/google/protobuf/descriptor.ts index fcf9f0783..fd413bccf 100644 --- a/integration/unknown-fields/google/protobuf/descriptor.ts +++ b/integration/unknown-fields/google/protobuf/descriptor.ts @@ -887,7 +887,7 @@ export const FileDescriptorSet = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileDescriptorSet { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileDescriptorSet(); (message as any)._unknownFields = {}; @@ -988,7 +988,7 @@ export const FileDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileDescriptorProto(); (message as any)._unknownFields = {}; @@ -1124,7 +1124,7 @@ export const DescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto(); (message as any)._unknownFields = {}; @@ -1208,7 +1208,7 @@ export const DescriptorProto_ExtensionRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto_ExtensionRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto_ExtensionRange(); (message as any)._unknownFields = {}; @@ -1268,7 +1268,7 @@ export const DescriptorProto_ReservedRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DescriptorProto_ReservedRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDescriptorProto_ReservedRange(); (message as any)._unknownFields = {}; @@ -1322,7 +1322,7 @@ export const ExtensionRangeOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ExtensionRangeOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseExtensionRangeOptions(); (message as any)._unknownFields = {}; @@ -1415,7 +1415,7 @@ export const FieldDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldDescriptorProto(); (message as any)._unknownFields = {}; @@ -1499,7 +1499,7 @@ export const OneofDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneofDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneofDescriptorProto(); (message as any)._unknownFields = {}; @@ -1565,7 +1565,7 @@ export const EnumDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumDescriptorProto(); (message as any)._unknownFields = {}; @@ -1631,7 +1631,7 @@ export const EnumDescriptorProto_EnumReservedRange = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumDescriptorProto_EnumReservedRange { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumDescriptorProto_EnumReservedRange(); (message as any)._unknownFields = {}; @@ -1691,7 +1691,7 @@ export const EnumValueDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumValueDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumValueDescriptorProto(); (message as any)._unknownFields = {}; @@ -1754,7 +1754,7 @@ export const ServiceDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ServiceDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseServiceDescriptorProto(); (message as any)._unknownFields = {}; @@ -1833,7 +1833,7 @@ export const MethodDescriptorProto = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MethodDescriptorProto { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMethodDescriptorProto(); (message as any)._unknownFields = {}; @@ -1981,7 +1981,7 @@ export const FileOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FileOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFileOptions(); (message as any)._unknownFields = {}; @@ -2110,7 +2110,7 @@ export const MessageOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MessageOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMessageOptions(); (message as any)._unknownFields = {}; @@ -2191,7 +2191,7 @@ export const FieldOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldOptions(); (message as any)._unknownFields = {}; @@ -2260,7 +2260,7 @@ export const OneofOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OneofOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneofOptions(); (message as any)._unknownFields = {}; @@ -2317,7 +2317,7 @@ export const EnumOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumOptions(); (message as any)._unknownFields = {}; @@ -2377,7 +2377,7 @@ export const EnumValueOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): EnumValueOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEnumValueOptions(); (message as any)._unknownFields = {}; @@ -2434,7 +2434,7 @@ export const ServiceOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ServiceOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseServiceOptions(); (message as any)._unknownFields = {}; @@ -2494,7 +2494,7 @@ export const MethodOptions = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MethodOptions { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMethodOptions(); (message as any)._unknownFields = {}; @@ -2577,7 +2577,7 @@ export const UninterpretedOption = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UninterpretedOption { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUninterpretedOption(); (message as any)._unknownFields = {}; @@ -2649,7 +2649,7 @@ export const UninterpretedOption_NamePart = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UninterpretedOption_NamePart { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUninterpretedOption_NamePart(); (message as any)._unknownFields = {}; @@ -2703,7 +2703,7 @@ export const SourceCodeInfo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SourceCodeInfo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSourceCodeInfo(); (message as any)._unknownFields = {}; @@ -2770,7 +2770,7 @@ export const SourceCodeInfo_Location = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SourceCodeInfo_Location { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSourceCodeInfo_Location(); (message as any)._unknownFields = {}; @@ -2847,7 +2847,7 @@ export const GeneratedCodeInfo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GeneratedCodeInfo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGeneratedCodeInfo(); (message as any)._unknownFields = {}; @@ -2909,7 +2909,7 @@ export const GeneratedCodeInfo_Annotation = { }, decode(input: _m0.Reader | Uint8Array, length?: number): GeneratedCodeInfo_Annotation { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGeneratedCodeInfo_Annotation(); (message as any)._unknownFields = {}; diff --git a/integration/unknown-fields/options.ts b/integration/unknown-fields/options.ts index f56eae9a9..91db8b57b 100644 --- a/integration/unknown-fields/options.ts +++ b/integration/unknown-fields/options.ts @@ -58,7 +58,7 @@ export const MyMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): MyMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMyMessage(); (message as any)._unknownFields = {}; @@ -115,7 +115,7 @@ export const RequestType = { }, decode(input: _m0.Reader | Uint8Array, length?: number): RequestType { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRequestType(); (message as any)._unknownFields = {}; @@ -160,7 +160,7 @@ export const ResponseType = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ResponseType { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseResponseType(); (message as any)._unknownFields = {}; @@ -196,7 +196,7 @@ export class MyServiceClientImpl implements MyService { MyMethod(request: RequestType): Promise { const data = RequestType.encode(request).finish(); const promise = this.rpc.request(this.service, "MyMethod", data); - return promise.then((data) => ResponseType.decode(new _m0.Reader(data))); + return promise.then((data) => ResponseType.decode(_m0.Reader.create(data))); } } diff --git a/integration/unknown-fields/something/something.ts b/integration/unknown-fields/something/something.ts index 2ce718a3f..aa2b43eb2 100644 --- a/integration/unknown-fields/something/something.ts +++ b/integration/unknown-fields/something/something.ts @@ -40,7 +40,7 @@ export const Something = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Something { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSomething(); (message as any)._unknownFields = {}; diff --git a/integration/use-date-false/google/protobuf/timestamp.ts b/integration/use-date-false/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/use-date-false/google/protobuf/timestamp.ts +++ b/integration/use-date-false/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/use-date-false/metadata.ts b/integration/use-date-false/metadata.ts index 9de157f94..4ca89d32d 100644 --- a/integration/use-date-false/metadata.ts +++ b/integration/use-date-false/metadata.ts @@ -21,7 +21,7 @@ export const Metadata = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Metadata { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMetadata(); while (reader.pos < end) { diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/use-date-string/use-date-string.ts b/integration/use-date-string/use-date-string.ts index 6c77fb921..06fcee0fd 100644 --- a/integration/use-date-string/use-date-string.ts +++ b/integration/use-date-string/use-date-string.ts @@ -42,7 +42,7 @@ export const Todo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo(); while (reader.pos < end) { @@ -149,7 +149,7 @@ export const Todo_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo_MapOfTimestampsEntry(); while (reader.pos < end) { diff --git a/integration/use-date-true/google/protobuf/empty.ts b/integration/use-date-true/google/protobuf/empty.ts index aa4359b94..cbc07ea77 100644 --- a/integration/use-date-true/google/protobuf/empty.ts +++ b/integration/use-date-true/google/protobuf/empty.ts @@ -27,7 +27,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index 4d815ca64..e3720e2ef 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -43,7 +43,7 @@ export const Todo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo(); while (reader.pos < end) { @@ -150,7 +150,7 @@ export const Todo_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo_MapOfTimestampsEntry(); while (reader.pos < end) { @@ -211,7 +211,7 @@ export class ClockClientImpl implements Clock { Now(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "Now", data); - return promise.then((data) => Timestamp.decode(new _m0.Reader(data))); + return promise.then((data) => Timestamp.decode(_m0.Reader.create(data))); } } diff --git a/integration/use-exact-types-false/foo.ts b/integration/use-exact-types-false/foo.ts index 5503d4684..73a437880 100644 --- a/integration/use-exact-types-false/foo.ts +++ b/integration/use-exact-types-false/foo.ts @@ -24,7 +24,7 @@ export const Foo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Foo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFoo(); while (reader.pos < end) { diff --git a/integration/use-map-type/google/protobuf/struct.ts b/integration/use-map-type/google/protobuf/struct.ts index ffcb6b973..7911e5573 100644 --- a/integration/use-map-type/google/protobuf/struct.ts +++ b/integration/use-map-type/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -210,7 +210,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -288,7 +288,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -409,7 +409,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/use-map-type/google/protobuf/timestamp.ts b/integration/use-map-type/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/use-map-type/google/protobuf/timestamp.ts +++ b/integration/use-map-type/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/use-map-type/use-map-type.ts b/integration/use-map-type/use-map-type.ts index 708a5b59e..67855dea9 100644 --- a/integration/use-map-type/use-map-type.ts +++ b/integration/use-map-type/use-map-type.ts @@ -57,7 +57,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity(); while (reader.pos < end) { @@ -130,7 +130,7 @@ export const Maps = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps(); while (reader.pos < end) { @@ -321,7 +321,7 @@ export const Maps_StrToEntityEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps_StrToEntityEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps_StrToEntityEntry(); while (reader.pos < end) { @@ -385,7 +385,7 @@ export const Maps_Int32ToInt32Entry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps_Int32ToInt32Entry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps_Int32ToInt32Entry(); while (reader.pos < end) { @@ -444,7 +444,7 @@ export const Maps_StringToBytesEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps_StringToBytesEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps_StringToBytesEntry(); while (reader.pos < end) { @@ -507,7 +507,7 @@ export const Maps_Int64ToInt64Entry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps_Int64ToInt64Entry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps_Int64ToInt64Entry(); while (reader.pos < end) { @@ -566,7 +566,7 @@ export const Maps_MapOfTimestampsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Maps_MapOfTimestampsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMaps_MapOfTimestampsEntry(); while (reader.pos < end) { diff --git a/integration/use-numeric-enum-json/google/protobuf/struct.ts b/integration/use-numeric-enum-json/google/protobuf/struct.ts index 78ae9698f..e68bbbbd9 100644 --- a/integration/use-numeric-enum-json/google/protobuf/struct.ts +++ b/integration/use-numeric-enum-json/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/use-numeric-enum-json/simple.ts b/integration/use-numeric-enum-json/simple.ts index eed465e4f..abb549777 100644 --- a/integration/use-numeric-enum-json/simple.ts +++ b/integration/use-numeric-enum-json/simple.ts @@ -83,7 +83,7 @@ export const Simple = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple(); while (reader.pos < end) { @@ -195,7 +195,7 @@ export const Simple_StateMapEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Simple_StateMapEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSimple_StateMapEntry(); while (reader.pos < end) { diff --git a/integration/use-objectid-true-external-import/objectid/objectid.ts b/integration/use-objectid-true-external-import/objectid/objectid.ts index a9cc80eab..89b9a64ea 100644 --- a/integration/use-objectid-true-external-import/objectid/objectid.ts +++ b/integration/use-objectid-true-external-import/objectid/objectid.ts @@ -20,7 +20,7 @@ export const ObjectId = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ObjectId { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObjectId(); while (reader.pos < end) { diff --git a/integration/use-objectid-true-external-import/use-objectid-true.ts b/integration/use-objectid-true-external-import/use-objectid-true.ts index 21a6cf021..bd994df08 100644 --- a/integration/use-objectid-true-external-import/use-objectid-true.ts +++ b/integration/use-objectid-true-external-import/use-objectid-true.ts @@ -43,7 +43,7 @@ export const Todo = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo(); while (reader.pos < end) { @@ -150,7 +150,7 @@ export const Todo_MapOfOidsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Todo_MapOfOidsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTodo_MapOfOidsEntry(); while (reader.pos < end) { diff --git a/integration/use-optionals-all/test.ts b/integration/use-optionals-all/test.ts index 48b129ef5..5d2b6aa98 100644 --- a/integration/use-optionals-all/test.ts +++ b/integration/use-optionals-all/test.ts @@ -197,7 +197,7 @@ export const OptionalsTest = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OptionalsTest { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOptionalsTest(); while (reader.pos < end) { @@ -461,7 +461,7 @@ export const OptionalsTest_TranslationsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): OptionalsTest_TranslationsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOptionalsTest_TranslationsEntry(); while (reader.pos < end) { @@ -516,7 +516,7 @@ export const Child = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Child { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseChild(); while (reader.pos < end) { diff --git a/integration/use-readonly-types/google/protobuf/field_mask.ts b/integration/use-readonly-types/google/protobuf/field_mask.ts index 7f2e0b019..90ced36df 100644 --- a/integration/use-readonly-types/google/protobuf/field_mask.ts +++ b/integration/use-readonly-types/google/protobuf/field_mask.ts @@ -221,7 +221,7 @@ export const FieldMask = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FieldMask { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFieldMask() as any; while (reader.pos < end) { diff --git a/integration/use-readonly-types/google/protobuf/struct.ts b/integration/use-readonly-types/google/protobuf/struct.ts index dab354cd9..d478f2b59 100644 --- a/integration/use-readonly-types/google/protobuf/struct.ts +++ b/integration/use-readonly-types/google/protobuf/struct.ts @@ -100,7 +100,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct() as any; while (reader.pos < end) { @@ -197,7 +197,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry() as any; while (reader.pos < end) { @@ -270,7 +270,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue() as any; while (reader.pos < end) { @@ -423,7 +423,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue() as any; while (reader.pos < end) { diff --git a/integration/use-readonly-types/use-readonly-types.ts b/integration/use-readonly-types/use-readonly-types.ts index 7f1f6f055..cd1a28734 100644 --- a/integration/use-readonly-types/use-readonly-types.ts +++ b/integration/use-readonly-types/use-readonly-types.ts @@ -88,7 +88,7 @@ export const Entity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Entity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEntity() as any; while (reader.pos < end) { @@ -246,7 +246,7 @@ export const SubEntity = { }, decode(input: _m0.Reader | Uint8Array, length?: number): SubEntity { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSubEntity() as any; while (reader.pos < end) { diff --git a/integration/value/google/protobuf/struct.ts b/integration/value/google/protobuf/struct.ts index cc3f1bebd..7307c351c 100644 --- a/integration/value/google/protobuf/struct.ts +++ b/integration/value/google/protobuf/struct.ts @@ -115,7 +115,7 @@ export const Struct = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { @@ -212,7 +212,7 @@ export const Struct_FieldsEntry = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { @@ -290,7 +290,7 @@ export const Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { @@ -411,7 +411,7 @@ export const ListValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ListValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { diff --git a/integration/value/google/protobuf/wrappers.ts b/integration/value/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/value/google/protobuf/wrappers.ts +++ b/integration/value/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/value/value.ts b/integration/value/value.ts index 4124b4282..1afcdb9ea 100644 --- a/integration/value/value.ts +++ b/integration/value/value.ts @@ -38,7 +38,7 @@ export const ValueMessage = { }, decode(input: _m0.Reader | Uint8Array, length?: number): ValueMessage { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValueMessage(); while (reader.pos < end) { diff --git a/integration/vector-tile/vector_tile.ts b/integration/vector-tile/vector_tile.ts index 8ce690057..232af9fec 100644 --- a/integration/vector-tile/vector_tile.ts +++ b/integration/vector-tile/vector_tile.ts @@ -92,7 +92,7 @@ export const Tile = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Tile { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTile(); while (reader.pos < end) { @@ -165,7 +165,7 @@ export const Tile_Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Tile_Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTile_Value(); while (reader.pos < end) { @@ -267,7 +267,7 @@ export const Tile_Feature = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Tile_Feature { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTile_Feature(); while (reader.pos < end) { @@ -375,7 +375,7 @@ export const Tile_Layer = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Tile_Layer { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTile_Layer(); while (reader.pos < end) { diff --git a/integration/wrappers-regression/google/protobuf/empty.ts b/integration/wrappers-regression/google/protobuf/empty.ts index aa4359b94..cbc07ea77 100644 --- a/integration/wrappers-regression/google/protobuf/empty.ts +++ b/integration/wrappers-regression/google/protobuf/empty.ts @@ -27,7 +27,7 @@ export const Empty = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Empty { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEmpty(); while (reader.pos < end) { diff --git a/integration/wrappers-regression/google/protobuf/timestamp.ts b/integration/wrappers-regression/google/protobuf/timestamp.ts index c7e0b76c4..f2eb558c2 100644 --- a/integration/wrappers-regression/google/protobuf/timestamp.ts +++ b/integration/wrappers-regression/google/protobuf/timestamp.ts @@ -127,7 +127,7 @@ export const Timestamp = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { diff --git a/integration/wrappers-regression/google/protobuf/wrappers.ts b/integration/wrappers-regression/google/protobuf/wrappers.ts index 5f08c7994..3d215fc57 100644 --- a/integration/wrappers-regression/google/protobuf/wrappers.ts +++ b/integration/wrappers-regression/google/protobuf/wrappers.ts @@ -107,7 +107,7 @@ export const DoubleValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDoubleValue(); while (reader.pos < end) { @@ -158,7 +158,7 @@ export const FloatValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseFloatValue(); while (reader.pos < end) { @@ -209,7 +209,7 @@ export const Int64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt64Value(); while (reader.pos < end) { @@ -260,7 +260,7 @@ export const UInt64Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt64Value(); while (reader.pos < end) { @@ -311,7 +311,7 @@ export const Int32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInt32Value(); while (reader.pos < end) { @@ -362,7 +362,7 @@ export const UInt32Value = { }, decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseUInt32Value(); while (reader.pos < end) { @@ -413,7 +413,7 @@ export const BoolValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoolValue(); while (reader.pos < end) { @@ -464,7 +464,7 @@ export const StringValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): StringValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStringValue(); while (reader.pos < end) { @@ -515,7 +515,7 @@ export const BytesValue = { }, decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue { - const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBytesValue(); while (reader.pos < end) { diff --git a/integration/wrappers-regression/wrappers-regression.ts b/integration/wrappers-regression/wrappers-regression.ts index b8147b2fc..9a9dcb540 100644 --- a/integration/wrappers-regression/wrappers-regression.ts +++ b/integration/wrappers-regression/wrappers-regression.ts @@ -29,25 +29,25 @@ export class ClockClientImpl implements Clock { Now(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "Now", data); - return promise.then((data) => Timestamp.decode(new _m0.Reader(data))); + return promise.then((data) => Timestamp.decode(_m0.Reader.create(data))); } NowString(request: StringValue): Promise { const data = StringValue.encode(request).finish(); const promise = this.rpc.request(this.service, "NowString", data); - return promise.then((data) => StringValue.decode(new _m0.Reader(data))); + return promise.then((data) => StringValue.decode(_m0.Reader.create(data))); } NowStringStream(request: Observable): Observable { const data = request.pipe(map((request) => StringValue.encode(request).finish())); const result = this.rpc.bidirectionalStreamingRequest(this.service, "NowStringStream", data); - return result.pipe(map((data) => StringValue.decode(new _m0.Reader(data)))); + return result.pipe(map((data) => StringValue.decode(_m0.Reader.create(data)))); } NowBool(request: Empty): Promise { const data = Empty.encode(request).finish(); const promise = this.rpc.request(this.service, "NowBool", data); - return promise.then((data) => BoolValue.decode(new _m0.Reader(data))); + return promise.then((data) => BoolValue.decode(_m0.Reader.create(data))); } } diff --git a/src/generate-services.ts b/src/generate-services.ts index ff94dd125..73b43f572 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -123,10 +123,10 @@ function generateRegularRpcMethod(ctx: Context, methodDesc: MethodDescriptorProt const maybeAbortSignal = options.useAbortSignal ? "abortSignal || undefined," : ""; let encode = code`${rawInputType}.encode(request).finish()`; - let decode = code`data => ${rawOutputType}.decode(new ${Reader}(data))`; + let decode = code`data => ${rawOutputType}.decode(${Reader}.create(data))`; // if (options.useDate && rawOutputType.toString().includes("Timestamp")) { - // decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`; + // decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(${Reader}.create(data)))`; // } if (methodDesc.clientStreaming) { if (options.useAsyncIterable) { @@ -297,7 +297,7 @@ function generateCachingRpcMethod( const response = await this.rpc.request(ctx, "${maybePrefixPackage(fileDesc, serviceDesc.name)}", "${ methodDesc.name }", data); - return ${outputType}.decode(new ${Reader}(response)); + return ${outputType}.decode(${Reader}.create(response)); }); return Promise.all(responses); } diff --git a/src/main.ts b/src/main.ts index 7c4af4974..163e11378 100644 --- a/src/main.ts +++ b/src/main.ts @@ -935,7 +935,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP input: ${Reader} | Uint8Array, length?: number, ): ${fullName} { - const reader = input instanceof ${Reader} ? input : new ${Reader}(input); + const reader = input instanceof ${Reader} ? input : ${Reader}.create(input); let end = length === undefined ? reader.len : reader.pos + length; `); From 134dabb18cbaeabf56ca60ed24a2417d41867288 Mon Sep 17 00:00:00 2001 From: ilikdoge Date: Sat, 18 Mar 2023 10:42:59 -0700 Subject: [PATCH 2/2] fix: simple service test mock value --- integration/simple/simple-service-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/simple/simple-service-test.ts b/integration/simple/simple-service-test.ts index 8549bc122..7b7b5aa98 100644 --- a/integration/simple/simple-service-test.ts +++ b/integration/simple/simple-service-test.ts @@ -3,7 +3,7 @@ import { PingRequest, PingServiceClientImpl } from './simple'; describe('simple', () => { it('binds rpc function', () => { const rpc = { - request: jest.fn().mockResolvedValue({}), + request: jest.fn().mockResolvedValue(Buffer.from([])), }; const client = new PingServiceClientImpl(rpc); const ping = client.ping;