@bufbuild/protobuf 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/from-binary.js +13 -3
- package/dist/cjs/to-binary.d.ts +1 -1
- package/dist/cjs/wire/base64-encoding.d.ts +1 -1
- package/dist/cjs/wire/base64-encoding.js +1 -1
- package/dist/cjs/wire/binary-encoding.d.ts +1 -1
- package/dist/cjs/wire/binary-encoding.js +1 -1
- package/dist/cjs/wire/text-encoding.d.ts +1 -1
- package/dist/esm/from-binary.js +14 -4
- package/dist/esm/to-binary.d.ts +1 -1
- package/dist/esm/wire/base64-encoding.d.ts +1 -1
- package/dist/esm/wire/base64-encoding.js +1 -1
- package/dist/esm/wire/binary-encoding.d.ts +1 -1
- package/dist/esm/wire/binary-encoding.js +1 -1
- package/dist/esm/wire/text-encoding.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/from-binary.js
CHANGED
|
@@ -20,6 +20,7 @@ const descriptors_js_1 = require("./descriptors.js");
|
|
|
20
20
|
const scalar_js_1 = require("./reflect/scalar.js");
|
|
21
21
|
const reflect_js_1 = require("./reflect/reflect.js");
|
|
22
22
|
const binary_encoding_js_1 = require("./wire/binary-encoding.js");
|
|
23
|
+
const varint_js_1 = require("./wire/varint.js");
|
|
23
24
|
// Default options for parsing binary data.
|
|
24
25
|
const readDefaults = {
|
|
25
26
|
readUnknownFields: true,
|
|
@@ -106,9 +107,14 @@ function readField(message, reader, field, wireType, options) {
|
|
|
106
107
|
message.set(field, val);
|
|
107
108
|
}
|
|
108
109
|
else if (options.readUnknownFields) {
|
|
109
|
-
const
|
|
110
|
+
const bytes = [];
|
|
111
|
+
(0, varint_js_1.varint32write)(val, bytes);
|
|
110
112
|
const unknownFields = (_a = message.getUnknown()) !== null && _a !== void 0 ? _a : [];
|
|
111
|
-
unknownFields.push({
|
|
113
|
+
unknownFields.push({
|
|
114
|
+
no: field.number,
|
|
115
|
+
wireType,
|
|
116
|
+
data: new Uint8Array(bytes),
|
|
117
|
+
});
|
|
112
118
|
message.setUnknown(unknownFields);
|
|
113
119
|
}
|
|
114
120
|
}
|
|
@@ -129,7 +135,11 @@ function readMapEntry(reader, map, options) {
|
|
|
129
135
|
const field = map.field();
|
|
130
136
|
let key;
|
|
131
137
|
let val;
|
|
132
|
-
|
|
138
|
+
// Read the length of the map entry, which is a varint.
|
|
139
|
+
const len = reader.uint32();
|
|
140
|
+
// WARNING: Calculate end AFTER advancing reader.pos (above), so that
|
|
141
|
+
// reader.pos is at the start of the map entry.
|
|
142
|
+
const end = reader.pos + len;
|
|
133
143
|
while (reader.pos < end) {
|
|
134
144
|
const [fieldNo] = reader.tag();
|
|
135
145
|
switch (fieldNo) {
|
package/dist/cjs/to-binary.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface BinaryWriteOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
writeUnknownFields: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare function toBinary<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, options?: Partial<BinaryWriteOptions>): Uint8Array
|
|
20
|
+
export declare function toBinary<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, options?: Partial<BinaryWriteOptions>): Uint8Array<ArrayBuffer>;
|
|
21
21
|
/**
|
|
22
22
|
* @private
|
|
23
23
|
*/
|
|
@@ -42,7 +42,7 @@ function base64Decode(base64Str) {
|
|
|
42
42
|
b = table[base64Str.charCodeAt(i)];
|
|
43
43
|
if (b === undefined) {
|
|
44
44
|
switch (base64Str[i]) {
|
|
45
|
-
// @ts-
|
|
45
|
+
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
|
|
46
46
|
case "=":
|
|
47
47
|
groupPos = 0; // reset state when padding found
|
|
48
48
|
case "\n":
|
|
@@ -86,7 +86,7 @@ export declare class BinaryWriter {
|
|
|
86
86
|
/**
|
|
87
87
|
* Return all bytes written and reset this writer.
|
|
88
88
|
*/
|
|
89
|
-
finish(): Uint8Array
|
|
89
|
+
finish(): Uint8Array<ArrayBuffer>;
|
|
90
90
|
/**
|
|
91
91
|
* Start a new fork for length-delimited data like a message
|
|
92
92
|
* or a packed repeated field.
|
|
@@ -329,7 +329,7 @@ class BinaryReader {
|
|
|
329
329
|
// ignore
|
|
330
330
|
}
|
|
331
331
|
break;
|
|
332
|
-
// @ts-
|
|
332
|
+
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
|
|
333
333
|
case WireType.Bit64:
|
|
334
334
|
this.pos += 4;
|
|
335
335
|
case WireType.Bit32:
|
package/dist/esm/from-binary.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
import { ScalarType } from "./descriptors.js";
|
|
15
15
|
import { scalarZeroValue } from "./reflect/scalar.js";
|
|
16
16
|
import { reflect } from "./reflect/reflect.js";
|
|
17
|
-
import { BinaryReader,
|
|
17
|
+
import { BinaryReader, WireType } from "./wire/binary-encoding.js";
|
|
18
|
+
import { varint32write } from "./wire/varint.js";
|
|
18
19
|
// Default options for parsing binary data.
|
|
19
20
|
const readDefaults = {
|
|
20
21
|
readUnknownFields: true,
|
|
@@ -101,9 +102,14 @@ export function readField(message, reader, field, wireType, options) {
|
|
|
101
102
|
message.set(field, val);
|
|
102
103
|
}
|
|
103
104
|
else if (options.readUnknownFields) {
|
|
104
|
-
const
|
|
105
|
+
const bytes = [];
|
|
106
|
+
varint32write(val, bytes);
|
|
105
107
|
const unknownFields = (_a = message.getUnknown()) !== null && _a !== void 0 ? _a : [];
|
|
106
|
-
unknownFields.push({
|
|
108
|
+
unknownFields.push({
|
|
109
|
+
no: field.number,
|
|
110
|
+
wireType,
|
|
111
|
+
data: new Uint8Array(bytes),
|
|
112
|
+
});
|
|
107
113
|
message.setUnknown(unknownFields);
|
|
108
114
|
}
|
|
109
115
|
}
|
|
@@ -124,7 +130,11 @@ function readMapEntry(reader, map, options) {
|
|
|
124
130
|
const field = map.field();
|
|
125
131
|
let key;
|
|
126
132
|
let val;
|
|
127
|
-
|
|
133
|
+
// Read the length of the map entry, which is a varint.
|
|
134
|
+
const len = reader.uint32();
|
|
135
|
+
// WARNING: Calculate end AFTER advancing reader.pos (above), so that
|
|
136
|
+
// reader.pos is at the start of the map entry.
|
|
137
|
+
const end = reader.pos + len;
|
|
128
138
|
while (reader.pos < end) {
|
|
129
139
|
const [fieldNo] = reader.tag();
|
|
130
140
|
switch (fieldNo) {
|
package/dist/esm/to-binary.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface BinaryWriteOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
writeUnknownFields: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare function toBinary<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, options?: Partial<BinaryWriteOptions>): Uint8Array
|
|
20
|
+
export declare function toBinary<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, options?: Partial<BinaryWriteOptions>): Uint8Array<ArrayBuffer>;
|
|
21
21
|
/**
|
|
22
22
|
* @private
|
|
23
23
|
*/
|
|
@@ -38,7 +38,7 @@ export function base64Decode(base64Str) {
|
|
|
38
38
|
b = table[base64Str.charCodeAt(i)];
|
|
39
39
|
if (b === undefined) {
|
|
40
40
|
switch (base64Str[i]) {
|
|
41
|
-
// @ts-
|
|
41
|
+
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
|
|
42
42
|
case "=":
|
|
43
43
|
groupPos = 0; // reset state when padding found
|
|
44
44
|
case "\n":
|
|
@@ -86,7 +86,7 @@ export declare class BinaryWriter {
|
|
|
86
86
|
/**
|
|
87
87
|
* Return all bytes written and reset this writer.
|
|
88
88
|
*/
|
|
89
|
-
finish(): Uint8Array
|
|
89
|
+
finish(): Uint8Array<ArrayBuffer>;
|
|
90
90
|
/**
|
|
91
91
|
* Start a new fork for length-delimited data like a message
|
|
92
92
|
* or a packed repeated field.
|
|
@@ -325,7 +325,7 @@ export class BinaryReader {
|
|
|
325
325
|
// ignore
|
|
326
326
|
}
|
|
327
327
|
break;
|
|
328
|
-
// @ts-
|
|
328
|
+
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
|
|
329
329
|
case WireType.Bit64:
|
|
330
330
|
this.pos += 4;
|
|
331
331
|
case WireType.Bit32:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protobuf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
5
|
"description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.",
|
|
6
6
|
"keywords": ["protobuf", "schema", "typescript", "ecmascript"],
|