@bufbuild/protobuf 0.0.5 → 0.0.8
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/binary-encoding.js +2 -2
- package/dist/cjs/descriptor-registry.js +18 -60
- package/dist/cjs/descriptor-set.js +15 -37
- package/dist/cjs/google/protobuf/any_pb.js +11 -8
- package/dist/cjs/google/protobuf/api_pb.js +19 -18
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +23 -22
- package/dist/cjs/google/protobuf/descriptor_pb.js +149 -148
- package/dist/cjs/google/protobuf/duration_pb.js +14 -12
- package/dist/cjs/google/protobuf/empty_pb.js +7 -6
- package/dist/cjs/google/protobuf/field_mask_pb.js +8 -7
- package/dist/cjs/google/protobuf/source_context_pb.js +7 -6
- package/dist/cjs/google/protobuf/struct_pb.js +26 -22
- package/dist/cjs/google/protobuf/timestamp_pb.js +12 -10
- package/dist/cjs/google/protobuf/type_pb.js +37 -33
- package/dist/cjs/google/protobuf/wrappers_pb.js +69 -66
- package/dist/cjs/index.js +40 -4
- package/dist/cjs/message.js +2 -1
- package/dist/cjs/private/binary-format-common.js +4 -3
- package/dist/cjs/private/binary-format-proto2.js +3 -6
- package/dist/cjs/private/binary-format-proto3.js +2 -5
- package/dist/cjs/private/enum.js +1 -1
- package/dist/cjs/private/json-format-common.js +6 -5
- package/dist/cjs/private/message-type.js +2 -1
- package/dist/cjs/proto-int64.js +1 -1
- package/dist/cjs/proto2.js +6 -8
- package/dist/cjs/proto3.js +9 -12
- package/dist/esm/binary-encoding.js +2 -2
- package/dist/esm/descriptor-registry.js +18 -60
- package/dist/esm/descriptor-set.js +15 -37
- package/dist/esm/google/protobuf/any_pb.js +6 -3
- package/dist/esm/google/protobuf/api_pb.js +2 -1
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +2 -1
- package/dist/esm/google/protobuf/descriptor_pb.js +2 -1
- package/dist/esm/google/protobuf/duration_pb.js +4 -2
- package/dist/esm/google/protobuf/empty_pb.js +2 -1
- package/dist/esm/google/protobuf/field_mask_pb.js +2 -1
- package/dist/esm/google/protobuf/source_context_pb.js +2 -1
- package/dist/esm/google/protobuf/struct_pb.js +6 -2
- package/dist/esm/google/protobuf/timestamp_pb.js +3 -1
- package/dist/esm/google/protobuf/type_pb.js +5 -1
- package/dist/esm/google/protobuf/wrappers_pb.js +4 -1
- package/dist/esm/index.js +25 -4
- package/dist/esm/message.js +2 -1
- package/dist/esm/private/binary-format-common.js +4 -3
- package/dist/esm/private/binary-format-proto2.js +3 -6
- package/dist/esm/private/binary-format-proto3.js +2 -5
- package/dist/esm/private/enum.js +1 -1
- package/dist/esm/private/json-format-common.js +6 -5
- package/dist/esm/private/message-type.js +2 -1
- package/dist/esm/proto-int64.js +1 -1
- package/dist/esm/proto2.js +6 -8
- package/dist/esm/proto3.js +9 -12
- package/dist/protobuf.cjs +2 -0
- package/dist/protobuf.cjs.map +1 -0
- package/dist/protobuf.esm.js +2 -0
- package/dist/protobuf.esm.js.map +1 -0
- package/dist/protobuf.modern.js +2 -0
- package/dist/protobuf.modern.js.map +1 -0
- package/dist/types/google/protobuf/any_pb.d.ts +6 -2
- package/dist/types/google/protobuf/api_pb.d.ts +5 -2
- package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +5 -2
- package/dist/types/google/protobuf/descriptor_pb.d.ts +5 -2
- package/dist/types/google/protobuf/duration_pb.d.ts +5 -2
- package/dist/types/google/protobuf/empty_pb.d.ts +5 -2
- package/dist/types/google/protobuf/field_mask_pb.d.ts +5 -2
- package/dist/types/google/protobuf/source_context_pb.d.ts +5 -2
- package/dist/types/google/protobuf/struct_pb.d.ts +5 -2
- package/dist/types/google/protobuf/timestamp_pb.d.ts +5 -2
- package/dist/types/google/protobuf/type_pb.d.ts +5 -2
- package/dist/types/google/protobuf/wrappers_pb.d.ts +5 -2
- package/dist/types/index.d.ts +31 -2
- package/package.json +3 -2
- package/dist/cjs/index-runtime.js +0 -42
- package/dist/cjs/index-wkt.js +0 -42
- package/dist/esm/index-runtime.js +0 -25
- package/dist/esm/index-wkt.js +0 -26
- package/dist/types/index-runtime.d.ts +0 -19
- package/dist/types/index-wkt.d.ts +0 -12
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { proto2 } from "../../proto2.js";
|
|
15
16
|
/**
|
|
16
17
|
* The protocol compiler can output a FileDescriptorSet containing the .proto
|
|
17
18
|
* files it parses.
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { protoInt64 } from "../../proto-int64.js";
|
|
16
|
+
import { proto3 } from "../../proto3.js";
|
|
15
17
|
/**
|
|
16
18
|
* A Duration represents a signed, fixed-length span of time represented
|
|
17
19
|
* as a count of seconds and fractions of seconds at nanosecond
|
|
@@ -116,7 +118,7 @@ export class Duration extends Message {
|
|
|
116
118
|
if (typeof match[2] == "string") {
|
|
117
119
|
const nanosStr = match[2] + "0".repeat(9 - match[2].length);
|
|
118
120
|
this.nanos = parseInt(nanosStr);
|
|
119
|
-
if (longSeconds <
|
|
121
|
+
if (longSeconds < protoInt64.zero) {
|
|
120
122
|
this.nanos = -this.nanos;
|
|
121
123
|
}
|
|
122
124
|
}
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { proto3 } from "../../proto3.js";
|
|
15
16
|
/**
|
|
16
17
|
* A generic empty message that you can re-use to avoid defining duplicated
|
|
17
18
|
* empty messages in your APIs. A typical example is to use it as the request
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { proto3 } from "../../proto3.js";
|
|
15
16
|
/**
|
|
16
17
|
* `FieldMask` represents a set of symbolic field paths, for example:
|
|
17
18
|
*
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { proto3 } from "../../proto3.js";
|
|
15
16
|
/**
|
|
16
17
|
* `SourceContext` represents information about the source of a
|
|
17
18
|
* protobuf element, like the file in which it is defined.
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
|
|
14
|
+
// @generated by protoc-gen-es v0.0.8 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
|
|
15
|
+
// @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
|
|
16
|
+
/* eslint-disable */
|
|
17
|
+
import { proto3 } from "../../proto3.js";
|
|
18
|
+
import { Message } from "../../message.js";
|
|
15
19
|
/**
|
|
16
20
|
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
17
21
|
* `Value` type union.
|
|
@@ -121,7 +125,7 @@ export class Value extends Message {
|
|
|
121
125
|
return this.kind.value;
|
|
122
126
|
case "structValue":
|
|
123
127
|
case "listValue":
|
|
124
|
-
return this.kind.value.toJson({
|
|
128
|
+
return this.kind.value.toJson(Object.assign(Object.assign({}, options), { emitDefaultValues: true }));
|
|
125
129
|
}
|
|
126
130
|
throw new Error("google.protobuf.Value must have a value");
|
|
127
131
|
}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { protoInt64 } from "../../proto-int64.js";
|
|
16
|
+
import { proto3 } from "../../proto3.js";
|
|
15
17
|
/**
|
|
16
18
|
* A Timestamp represents a point in time independent of any time zone or local
|
|
17
19
|
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
|
|
14
|
+
// @generated by protoc-gen-es v0.0.8 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
|
|
15
|
+
// @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
|
|
16
|
+
/* eslint-disable */
|
|
17
|
+
import { proto3 } from "../../proto3.js";
|
|
18
|
+
import { Message } from "../../message.js";
|
|
15
19
|
import { SourceContext } from "./source_context_pb.js";
|
|
16
20
|
import { Any } from "./any_pb.js";
|
|
17
21
|
/**
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Message
|
|
14
|
+
import { Message } from "../../message.js";
|
|
15
|
+
import { proto3 } from "../../proto3.js";
|
|
16
|
+
import { ScalarType } from "../../field.js";
|
|
17
|
+
import { protoInt64 } from "../../proto-int64.js";
|
|
15
18
|
/**
|
|
16
19
|
* Wrapper message for `double`.
|
|
17
20
|
*
|
package/dist/esm/index.js
CHANGED
|
@@ -11,7 +11,28 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
14
|
+
export { proto3 } from "./proto3.js";
|
|
15
|
+
export { proto2 } from "./proto2.js";
|
|
16
|
+
export { protoInt64 } from "./proto-int64.js";
|
|
17
|
+
export { protoBase64 } from "./proto-base64.js";
|
|
18
|
+
export { Message, } from "./message.js";
|
|
19
|
+
export { ScalarType } from "./field.js";
|
|
20
|
+
export { MethodKind, MethodIdempotency } from "./service-type.js";
|
|
21
|
+
export { TypeRegistry } from "./type-registry.js";
|
|
22
|
+
export { DescriptorRegistry } from "./descriptor-registry.js";
|
|
23
|
+
export { DescriptorSet } from "./descriptor-set.js";
|
|
24
|
+
export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
|
|
25
|
+
export {} from "./json-format.js";
|
|
26
|
+
// ideally, we would export these types with sub-path exports:
|
|
27
|
+
export * from "./google/protobuf/compiler/plugin_pb.js";
|
|
28
|
+
export * from "./google/protobuf/api_pb.js";
|
|
29
|
+
export * from "./google/protobuf/any_pb.js";
|
|
30
|
+
export * from "./google/protobuf/descriptor_pb.js";
|
|
31
|
+
export * from "./google/protobuf/duration_pb.js";
|
|
32
|
+
export * from "./google/protobuf/empty_pb.js";
|
|
33
|
+
export * from "./google/protobuf/field_mask_pb.js";
|
|
34
|
+
export * from "./google/protobuf/source_context_pb.js";
|
|
35
|
+
export * from "./google/protobuf/struct_pb.js";
|
|
36
|
+
export * from "./google/protobuf/timestamp_pb.js";
|
|
37
|
+
export * from "./google/protobuf/type_pb.js";
|
|
38
|
+
export * from "./google/protobuf/wrappers_pb.js";
|
package/dist/esm/message.js
CHANGED
|
@@ -81,8 +81,9 @@ export class Message {
|
|
|
81
81
|
* Serialize the message to a JSON string.
|
|
82
82
|
*/
|
|
83
83
|
toJsonString(options) {
|
|
84
|
+
var _a;
|
|
84
85
|
const value = this.toJson(options);
|
|
85
|
-
return JSON.stringify(value, null, options
|
|
86
|
+
return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
89
|
* Retrieve the MessageType of this message - a singleton that represents
|
|
@@ -29,17 +29,18 @@ const writeDefaults = {
|
|
|
29
29
|
writerFactory: () => new BinaryWriter(),
|
|
30
30
|
};
|
|
31
31
|
function makeReadOptions(options) {
|
|
32
|
-
return options ? {
|
|
32
|
+
return options ? Object.assign(Object.assign({}, readDefaults), options) : readDefaults;
|
|
33
33
|
}
|
|
34
34
|
function makeWriteOptions(options) {
|
|
35
|
-
return options ? {
|
|
35
|
+
return options ? Object.assign(Object.assign({}, writeDefaults), options) : writeDefaults;
|
|
36
36
|
}
|
|
37
37
|
export function makeBinaryFormatCommon() {
|
|
38
38
|
return {
|
|
39
39
|
makeReadOptions,
|
|
40
40
|
makeWriteOptions,
|
|
41
41
|
listUnknownFields(message) {
|
|
42
|
-
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = message[unknownFieldsSymbol]) !== null && _a !== void 0 ? _a : [];
|
|
43
44
|
},
|
|
44
45
|
discardUnknownFields(message) {
|
|
45
46
|
delete message[unknownFieldsSymbol];
|
|
@@ -15,9 +15,7 @@ import { ScalarType } from "../field.js";
|
|
|
15
15
|
import { makeBinaryFormatCommon, writeMapEntry, writeMessageField, writePacked, writeScalar, } from "./binary-format-common.js";
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions, no-case-declarations, prefer-const */
|
|
17
17
|
export function makeBinaryFormatProto2() {
|
|
18
|
-
return {
|
|
19
|
-
...makeBinaryFormatCommon(),
|
|
20
|
-
writeMessage(message, writer, options) {
|
|
18
|
+
return Object.assign(Object.assign({}, makeBinaryFormatCommon()), { writeMessage(message, writer, options) {
|
|
21
19
|
const type = message.getType();
|
|
22
20
|
let field;
|
|
23
21
|
try {
|
|
@@ -81,7 +79,7 @@ export function makeBinaryFormatProto2() {
|
|
|
81
79
|
}
|
|
82
80
|
catch (e) {
|
|
83
81
|
let m = field
|
|
84
|
-
? `cannot encode field ${type.typeName}.${field
|
|
82
|
+
? `cannot encode field ${type.typeName}.${field === null || field === void 0 ? void 0 : field.name} to binary`
|
|
85
83
|
: `cannot encode message ${type.typeName} to binary`;
|
|
86
84
|
let r = e instanceof Error ? e.message : String(e);
|
|
87
85
|
throw new Error(m + (r.length > 0 ? `: ${r}` : ""));
|
|
@@ -90,6 +88,5 @@ export function makeBinaryFormatProto2() {
|
|
|
90
88
|
this.writeUnknownFields(message, writer);
|
|
91
89
|
}
|
|
92
90
|
return writer;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
91
|
+
} });
|
|
95
92
|
}
|
|
@@ -15,9 +15,7 @@ import { ScalarType } from "../field.js";
|
|
|
15
15
|
import { makeBinaryFormatCommon, writeMapEntry, writeMessageField, writePacked, writeScalar, } from "./binary-format-common.js";
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions, prefer-const, no-case-declarations */
|
|
17
17
|
export function makeBinaryFormatProto3() {
|
|
18
|
-
return {
|
|
19
|
-
...makeBinaryFormatCommon(),
|
|
20
|
-
writeMessage(message, writer, options) {
|
|
18
|
+
return Object.assign(Object.assign({}, makeBinaryFormatCommon()), { writeMessage(message, writer, options) {
|
|
21
19
|
const type = message.getType();
|
|
22
20
|
for (const field of type.fields.byNumber()) {
|
|
23
21
|
let value, // this will be our field value, whether it is member of a oneof or regular field
|
|
@@ -73,6 +71,5 @@ export function makeBinaryFormatProto3() {
|
|
|
73
71
|
this.writeUnknownFields(message, writer);
|
|
74
72
|
}
|
|
75
73
|
return writer;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
74
|
+
} });
|
|
78
75
|
}
|
package/dist/esm/private/enum.js
CHANGED
|
@@ -76,7 +76,7 @@ export function makeEnumType(typeName, values
|
|
|
76
76
|
export function makeEnum(typeName, values, opt) {
|
|
77
77
|
const enumObject = {};
|
|
78
78
|
for (const value of values) {
|
|
79
|
-
const name = makeEnumValueName(value, opt
|
|
79
|
+
const name = makeEnumValueName(value, opt === null || opt === void 0 ? void 0 : opt.sharedPrefix);
|
|
80
80
|
enumObject[name] = value.no;
|
|
81
81
|
enumObject[value.no] = name;
|
|
82
82
|
}
|
|
@@ -29,10 +29,10 @@ const jsonWriteDefaults = {
|
|
|
29
29
|
prettySpaces: 0,
|
|
30
30
|
};
|
|
31
31
|
function makeReadOptions(options) {
|
|
32
|
-
return options ? {
|
|
32
|
+
return options ? Object.assign(Object.assign({}, jsonReadDefaults), options) : jsonReadDefaults;
|
|
33
33
|
}
|
|
34
34
|
function makeWriteOptions(options) {
|
|
35
|
-
return options ? {
|
|
35
|
+
return options ? Object.assign(Object.assign({}, jsonWriteDefaults), options) : jsonWriteDefaults;
|
|
36
36
|
}
|
|
37
37
|
export function makeJsonFormatCommon(makeWriteField) {
|
|
38
38
|
const writeField = makeWriteField(writeEnum, writeScalar);
|
|
@@ -43,7 +43,7 @@ export function makeJsonFormatCommon(makeWriteField) {
|
|
|
43
43
|
if (json == null || Array.isArray(json) || typeof json != "object") {
|
|
44
44
|
throw new Error(`cannot decode message ${type.typeName} from JSON: ${this.debug(json)}`);
|
|
45
45
|
}
|
|
46
|
-
message = message
|
|
46
|
+
message = message !== null && message !== void 0 ? message : new type();
|
|
47
47
|
const oneofSeen = {};
|
|
48
48
|
for (const [jsonKey, jsonValue] of Object.entries(json)) {
|
|
49
49
|
const field = type.fields.findJsonName(jsonKey);
|
|
@@ -382,13 +382,14 @@ function readEnum(type, json, ignoreUnknownFields) {
|
|
|
382
382
|
case "string":
|
|
383
383
|
const value = type.findName(json);
|
|
384
384
|
if (value || ignoreUnknownFields) {
|
|
385
|
-
return value
|
|
385
|
+
return value === null || value === void 0 ? void 0 : value.no;
|
|
386
386
|
}
|
|
387
387
|
break;
|
|
388
388
|
}
|
|
389
389
|
throw new Error(`cannot decode enum ${type.typeName} from JSON: ${debugJsonValue(json)}`);
|
|
390
390
|
}
|
|
391
391
|
function writeEnum(type, value, emitIntrinsicDefault, enumAsInteger) {
|
|
392
|
+
var _a;
|
|
392
393
|
if (value === undefined) {
|
|
393
394
|
return value;
|
|
394
395
|
}
|
|
@@ -403,7 +404,7 @@ function writeEnum(type, value, emitIntrinsicDefault, enumAsInteger) {
|
|
|
403
404
|
return null;
|
|
404
405
|
}
|
|
405
406
|
const val = type.findNumber(value);
|
|
406
|
-
return val
|
|
407
|
+
return (_a = val === null || val === void 0 ? void 0 : val.name) !== null && _a !== void 0 ? _a : value; // if we don't know the enum value, just return the number
|
|
407
408
|
}
|
|
408
409
|
function writeScalar(type, value, emitIntrinsicDefault) {
|
|
409
410
|
if (value === undefined) {
|
|
@@ -16,7 +16,8 @@ import { Message, } from "../message.js";
|
|
|
16
16
|
* Create a new message type using the given runtime.
|
|
17
17
|
*/
|
|
18
18
|
export function makeMessageType(runtime, typeName, fields, opt) {
|
|
19
|
-
|
|
19
|
+
var _a;
|
|
20
|
+
const localName = (_a = opt === null || opt === void 0 ? void 0 : opt.localName) !== null && _a !== void 0 ? _a : typeName.substring(typeName.lastIndexOf(".") + 1);
|
|
20
21
|
const type = {
|
|
21
22
|
[localName]: function (data) {
|
|
22
23
|
runtime.util.initFields(this);
|
package/dist/esm/proto-int64.js
CHANGED
|
@@ -15,7 +15,7 @@ import { int64fromString, int64toString } from "./google/varint.js";
|
|
|
15
15
|
function makeInt64Support() {
|
|
16
16
|
const dv = new DataView(new ArrayBuffer(8));
|
|
17
17
|
// note that Safari 14 implements BigInt, but not the DataView methods
|
|
18
|
-
const ok = globalThis.BigInt !== undefined &&
|
|
18
|
+
const ok = globalThis.BigInt !== undefined &&
|
|
19
19
|
typeof dv.getBigInt64 === "function" &&
|
|
20
20
|
typeof dv.getBigUint64 === "function" &&
|
|
21
21
|
typeof dv.setBigInt64 === "function" &&
|
package/dist/esm/proto2.js
CHANGED
|
@@ -21,9 +21,7 @@ import { makeJsonFormatProto2 } from "./private/json-format-proto2.js";
|
|
|
21
21
|
/**
|
|
22
22
|
* Provides functionality for messages defined with the proto2 syntax.
|
|
23
23
|
*/
|
|
24
|
-
export const proto2 = makeProtoRuntime("proto2", makeJsonFormatProto2(), makeBinaryFormatProto2(), {
|
|
25
|
-
...makeUtilCommon(),
|
|
26
|
-
newFieldList(fields) {
|
|
24
|
+
export const proto2 = makeProtoRuntime("proto2", makeJsonFormatProto2(), makeBinaryFormatProto2(), Object.assign(Object.assign({}, makeUtilCommon()), { newFieldList(fields) {
|
|
27
25
|
return new InternalFieldList(fields, normalizeFieldInfosProto2);
|
|
28
26
|
},
|
|
29
27
|
initFields(target) {
|
|
@@ -52,10 +50,10 @@ export const proto2 = makeProtoRuntime("proto2", makeJsonFormatProto2(), makeBin
|
|
|
52
50
|
break;
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
53
|
+
} }));
|
|
57
54
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
|
|
58
55
|
function normalizeFieldInfosProto2(fieldInfos) {
|
|
56
|
+
var _a, _b, _c;
|
|
59
57
|
const r = [];
|
|
60
58
|
let o;
|
|
61
59
|
for (const field of typeof fieldInfos == "function"
|
|
@@ -63,10 +61,10 @@ function normalizeFieldInfosProto2(fieldInfos) {
|
|
|
63
61
|
: fieldInfos) {
|
|
64
62
|
const f = field;
|
|
65
63
|
f.localName = makeFieldName(field.name, field.oneof !== undefined);
|
|
66
|
-
f.jsonName = field.jsonName
|
|
67
|
-
f.repeated = field.repeated
|
|
64
|
+
f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : makeJsonName(field.name);
|
|
65
|
+
f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;
|
|
68
66
|
// In contrast to proto3, repeated fields are unpacked except when explicitly specified.
|
|
69
|
-
f.packed = field.packed
|
|
67
|
+
f.packed = (_c = field.packed) !== null && _c !== void 0 ? _c : false;
|
|
70
68
|
// We do not surface options at this time
|
|
71
69
|
// f.options = field.options ?? emptyReadonlyObject;
|
|
72
70
|
if (field.oneof !== undefined) {
|
package/dist/esm/proto3.js
CHANGED
|
@@ -23,9 +23,7 @@ import { makeFieldName, makeJsonName } from "./private/names.js";
|
|
|
23
23
|
/**
|
|
24
24
|
* Provides functionality for messages defined with the proto3 syntax.
|
|
25
25
|
*/
|
|
26
|
-
export const proto3 = makeProtoRuntime("proto3", makeJsonFormatProto3(), makeBinaryFormatProto3(), {
|
|
27
|
-
...makeUtilCommon(),
|
|
28
|
-
newFieldList(fields) {
|
|
26
|
+
export const proto3 = makeProtoRuntime("proto3", makeJsonFormatProto3(), makeBinaryFormatProto3(), Object.assign(Object.assign({}, makeUtilCommon()), { newFieldList(fields) {
|
|
29
27
|
return new InternalFieldList(fields, normalizeFieldInfosProto3);
|
|
30
28
|
},
|
|
31
29
|
initFields(target) {
|
|
@@ -56,10 +54,10 @@ export const proto3 = makeProtoRuntime("proto3", makeJsonFormatProto3(), makeBin
|
|
|
56
54
|
break;
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
57
|
+
} }));
|
|
61
58
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
|
|
62
59
|
function normalizeFieldInfosProto3(fieldInfos) {
|
|
60
|
+
var _a, _b, _c;
|
|
63
61
|
const r = [];
|
|
64
62
|
let o;
|
|
65
63
|
for (const field of typeof fieldInfos == "function"
|
|
@@ -67,19 +65,18 @@ function normalizeFieldInfosProto3(fieldInfos) {
|
|
|
67
65
|
: fieldInfos) {
|
|
68
66
|
const f = field;
|
|
69
67
|
f.localName = makeFieldName(field.name, field.oneof !== undefined);
|
|
70
|
-
f.jsonName = field.jsonName
|
|
71
|
-
f.repeated = field.repeated
|
|
68
|
+
f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : makeJsonName(field.name);
|
|
69
|
+
f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;
|
|
72
70
|
// From the proto3 language guide:
|
|
73
71
|
// > In proto3, repeated fields of scalar numeric types are packed by default.
|
|
74
72
|
// This information is incomplete - according to the conformance tests, BOOL
|
|
75
73
|
// and ENUM are packed by default as well. This means only STRING and BYTES
|
|
76
74
|
// are not packed by default, which makes sense because they are length-delimited.
|
|
77
75
|
f.packed =
|
|
78
|
-
field.packed
|
|
79
|
-
(field.kind == "
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
field.T != ScalarType.STRING));
|
|
76
|
+
(_c = field.packed) !== null && _c !== void 0 ? _c : (field.kind == "enum" ||
|
|
77
|
+
(field.kind == "scalar" &&
|
|
78
|
+
field.T != ScalarType.BYTES &&
|
|
79
|
+
field.T != ScalarType.STRING));
|
|
83
80
|
// We do not surface options at this time
|
|
84
81
|
// f.options = field.options ?? emptyReadonlyObject;
|
|
85
82
|
if (field.oneof !== undefined) {
|