@bufbuild/protobuf 1.7.2 → 1.9.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/binary-encoding.d.ts +2 -2
- package/dist/cjs/codegen-info.d.ts +6 -1
- package/dist/cjs/codegen-info.js +4 -3
- package/dist/cjs/create-descriptor-set.js +45 -33
- package/dist/cjs/create-registry-from-desc.js +60 -110
- package/dist/cjs/descriptor-set.d.ts +13 -9
- package/dist/cjs/field.d.ts +25 -51
- package/dist/cjs/field.js +0 -66
- package/dist/cjs/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/cjs/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/cjs/google/protobuf/descriptor_pb.js +23 -10
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/google/protobuf/wrappers_pb.js +19 -19
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/is-message.d.ts +22 -0
- package/dist/cjs/is-message.js +52 -0
- package/dist/cjs/json-format.d.ts +1 -2
- package/dist/cjs/message.d.ts +1 -0
- package/dist/cjs/message.js +1 -0
- package/dist/cjs/private/binary-format.d.ts +7 -0
- package/dist/cjs/private/{binary-format-common.js → binary-format.js} +150 -53
- package/dist/cjs/private/extensions.js +1 -1
- package/dist/cjs/private/feature-set.js +1 -1
- package/dist/cjs/private/field-normalize.d.ts +9 -0
- package/dist/cjs/private/field-normalize.js +69 -0
- package/dist/cjs/private/field-wrapper.d.ts +1 -1
- package/dist/cjs/private/field-wrapper.js +12 -12
- package/dist/cjs/private/field.d.ts +1 -0
- package/dist/cjs/private/field.js +1 -0
- package/dist/cjs/private/json-format.d.ts +2 -0
- package/dist/cjs/private/{json-format-common.js → json-format.js} +261 -170
- package/dist/cjs/private/names.js +3 -3
- package/dist/cjs/private/proto-runtime.d.ts +1 -1
- package/dist/cjs/private/proto-runtime.js +8 -4
- package/dist/cjs/private/reflect.d.ts +9 -0
- package/dist/cjs/private/reflect.js +79 -0
- package/dist/cjs/private/reify-wkt.js +11 -11
- package/dist/cjs/private/scalars.d.ts +9 -18
- package/dist/cjs/private/scalars.js +36 -80
- package/dist/cjs/private/text-format.d.ts +1 -1
- package/dist/cjs/private/text-format.js +17 -17
- package/dist/cjs/private/util-common.js +20 -14
- package/dist/cjs/proto-delimited.js +2 -3
- package/dist/cjs/proto2.js +29 -68
- package/dist/cjs/proto3.js +30 -77
- package/dist/cjs/scalar.d.ts +53 -0
- package/dist/cjs/scalar.js +81 -0
- package/dist/cjs/to-plain-message.js +3 -4
- package/dist/esm/binary-encoding.d.ts +2 -2
- package/dist/esm/codegen-info.d.ts +6 -1
- package/dist/esm/codegen-info.js +6 -5
- package/dist/esm/create-descriptor-set.js +22 -10
- package/dist/esm/create-registry-from-desc.js +62 -111
- package/dist/esm/descriptor-set.d.ts +13 -9
- package/dist/esm/descriptor-set.js +1 -1
- package/dist/esm/field.d.ts +25 -51
- package/dist/esm/field.js +1 -65
- package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/esm/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/esm/google/protobuf/descriptor_pb.js +23 -10
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/is-message.d.ts +22 -0
- package/dist/esm/is-message.js +48 -0
- package/dist/esm/json-format.d.ts +1 -2
- package/dist/esm/json-format.js +1 -1
- package/dist/esm/message.d.ts +1 -0
- package/dist/esm/message.js +1 -0
- package/dist/esm/private/binary-format.d.ts +7 -0
- package/dist/esm/private/{binary-format-common.js → binary-format.js} +126 -25
- package/dist/esm/private/extensions.js +2 -2
- package/dist/esm/private/feature-set.js +1 -1
- package/dist/esm/private/field-normalize.d.ts +9 -0
- package/dist/esm/private/field-normalize.js +65 -0
- package/dist/esm/private/field-wrapper.d.ts +1 -1
- package/dist/esm/private/field-wrapper.js +3 -2
- package/dist/esm/private/field.d.ts +1 -0
- package/dist/esm/private/field.js +1 -0
- package/dist/esm/private/json-format.d.ts +2 -0
- package/dist/esm/private/{json-format-common.js → json-format.js} +228 -136
- package/dist/esm/private/names.js +3 -3
- package/dist/esm/private/proto-runtime.d.ts +1 -1
- package/dist/esm/private/proto-runtime.js +8 -4
- package/dist/esm/private/reflect.d.ts +9 -0
- package/dist/esm/private/reflect.js +74 -0
- package/dist/esm/private/reify-wkt.js +1 -1
- package/dist/esm/private/scalars.d.ts +9 -18
- package/dist/esm/private/scalars.js +15 -59
- package/dist/esm/private/text-format.d.ts +1 -1
- package/dist/esm/private/text-format.js +1 -1
- package/dist/esm/private/util-common.js +13 -6
- package/dist/esm/proto-delimited.js +2 -3
- package/dist/esm/proto2.js +29 -68
- package/dist/esm/proto3.js +31 -78
- package/dist/esm/scalar.d.ts +53 -0
- package/dist/esm/scalar.js +78 -0
- package/dist/esm/to-plain-message.js +3 -2
- package/package.json +4 -10
- package/dist/cjs/private/binary-format-common.d.ts +0 -13
- package/dist/cjs/private/binary-format-proto2.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto2.js +0 -91
- package/dist/cjs/private/binary-format-proto3.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto3.js +0 -83
- package/dist/cjs/private/json-format-common.d.ts +0 -9
- package/dist/cjs/private/json-format-proto2.d.ts +0 -2
- package/dist/cjs/private/json-format-proto2.js +0 -103
- package/dist/cjs/private/json-format-proto3.d.ts +0 -2
- package/dist/cjs/private/json-format-proto3.js +0 -94
- package/dist/esm/private/binary-format-common.d.ts +0 -13
- package/dist/esm/private/binary-format-proto2.d.ts +0 -2
- package/dist/esm/private/binary-format-proto2.js +0 -87
- package/dist/esm/private/binary-format-proto3.d.ts +0 -2
- package/dist/esm/private/binary-format-proto3.js +0 -79
- package/dist/esm/private/json-format-common.d.ts +0 -9
- package/dist/esm/private/json-format-proto2.d.ts +0 -2
- package/dist/esm/private/json-format-proto2.js +0 -99
- package/dist/esm/private/json-format-proto3.d.ts +0 -2
- package/dist/esm/private/json-format-proto3.js +0 -90
- package/dist/proxy/index.d.ts +0 -1
- package/dist/proxy/index.js +0 -1
|
@@ -11,7 +11,7 @@
|
|
|
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 {
|
|
14
|
+
import { scalarZeroValue } from "./scalars.js";
|
|
15
15
|
import { WireType } from "../binary-encoding.js";
|
|
16
16
|
/**
|
|
17
17
|
* Create a new extension using the given runtime.
|
|
@@ -55,7 +55,7 @@ function initExtensionField(ext) {
|
|
|
55
55
|
case "enum":
|
|
56
56
|
return field.T.values[0].no;
|
|
57
57
|
case "scalar":
|
|
58
|
-
return
|
|
58
|
+
return scalarZeroValue(field.T, field.L);
|
|
59
59
|
case "message":
|
|
60
60
|
// eslint-disable-next-line no-case-declarations
|
|
61
61
|
const T = field.T, value = new T();
|
|
@@ -18,7 +18,7 @@ import { protoBase64 } from "../proto-base64.js";
|
|
|
18
18
|
*/
|
|
19
19
|
function getFeatureSetDefaults(options) {
|
|
20
20
|
return FeatureSetDefaults.fromBinary(protoBase64.dec(
|
|
21
|
-
/*upstream-inject-feature-defaults-start*/ "
|
|
21
|
+
/*upstream-inject-feature-defaults-start*/ "ChESDAgBEAIYAiADKAEwAhjmBwoREgwIAhABGAEgAigBMAEY5wcKERIMCAEQARgBIAIoATABGOgHIOYHKOgH" /*upstream-inject-feature-defaults-end*/), options);
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Create an edition feature resolver with the given feature set defaults, or
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldListSource } from "./field-list.js";
|
|
2
|
+
import type { FieldInfo } from "../field.js";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a collection of field info to an array of normalized FieldInfo.
|
|
5
|
+
*
|
|
6
|
+
* The argument `packedByDefault` specifies whether fields that do not specify
|
|
7
|
+
* `packed` should be packed (proto3) or unpacked (proto2).
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeFieldInfos(fieldInfos: FieldListSource, packedByDefault: boolean): FieldInfo[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { InternalOneofInfo } from "./field.js";
|
|
15
|
+
import { fieldJsonName, localFieldName } from "./names.js";
|
|
16
|
+
import { LongType, ScalarType } from "../scalar.js";
|
|
17
|
+
/**
|
|
18
|
+
* Convert a collection of field info to an array of normalized FieldInfo.
|
|
19
|
+
*
|
|
20
|
+
* The argument `packedByDefault` specifies whether fields that do not specify
|
|
21
|
+
* `packed` should be packed (proto3) or unpacked (proto2).
|
|
22
|
+
*/
|
|
23
|
+
export function normalizeFieldInfos(fieldInfos, packedByDefault) {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25
|
+
const r = [];
|
|
26
|
+
let o;
|
|
27
|
+
for (const field of typeof fieldInfos == "function"
|
|
28
|
+
? fieldInfos()
|
|
29
|
+
: fieldInfos) {
|
|
30
|
+
const f = field;
|
|
31
|
+
f.localName = localFieldName(field.name, field.oneof !== undefined);
|
|
32
|
+
f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : fieldJsonName(field.name);
|
|
33
|
+
f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;
|
|
34
|
+
if (field.kind == "scalar") {
|
|
35
|
+
f.L = (_c = field.L) !== null && _c !== void 0 ? _c : LongType.BIGINT;
|
|
36
|
+
}
|
|
37
|
+
f.delimited = (_d = field.delimited) !== null && _d !== void 0 ? _d : false;
|
|
38
|
+
f.req = (_e = field.req) !== null && _e !== void 0 ? _e : false;
|
|
39
|
+
f.opt = (_f = field.opt) !== null && _f !== void 0 ? _f : false;
|
|
40
|
+
if (field.packed === undefined) {
|
|
41
|
+
if (packedByDefault) {
|
|
42
|
+
f.packed =
|
|
43
|
+
field.kind == "enum" ||
|
|
44
|
+
(field.kind == "scalar" &&
|
|
45
|
+
field.T != ScalarType.BYTES &&
|
|
46
|
+
field.T != ScalarType.STRING);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
f.packed = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// We do not surface options at this time
|
|
53
|
+
// f.options = field.options ?? emptyReadonlyObject;
|
|
54
|
+
if (field.oneof !== undefined) {
|
|
55
|
+
const ooname = typeof field.oneof == "string" ? field.oneof : field.oneof.name;
|
|
56
|
+
if (!o || o.name != ooname) {
|
|
57
|
+
o = new InternalOneofInfo(ooname);
|
|
58
|
+
}
|
|
59
|
+
f.oneof = o;
|
|
60
|
+
o.addField(f);
|
|
61
|
+
}
|
|
62
|
+
r.push(f);
|
|
63
|
+
}
|
|
64
|
+
return r;
|
|
65
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Message } from "../message.js";
|
|
2
2
|
import type { MessageType } from "../message-type.js";
|
|
3
3
|
import type { DescExtension, DescField } from "../descriptor-set.js";
|
|
4
|
-
import { ScalarType } from "../
|
|
4
|
+
import { ScalarType } from "../scalar.js";
|
|
5
5
|
/**
|
|
6
6
|
* A field wrapper unwraps a message to a primitive value that is more
|
|
7
7
|
* ergonomic for use as a message field.
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { Message } from "../message.js";
|
|
15
|
-
import { ScalarType } from "../
|
|
15
|
+
import { ScalarType } from "../scalar.js";
|
|
16
|
+
import { isMessage } from "../is-message.js";
|
|
16
17
|
/**
|
|
17
18
|
* Wrap a primitive message field value in its corresponding wrapper
|
|
18
19
|
* message. This function is idempotent.
|
|
19
20
|
*/
|
|
20
21
|
export function wrapField(type, value) {
|
|
21
|
-
if (value
|
|
22
|
+
if (isMessage(value) || !type.fieldWrapper) {
|
|
22
23
|
return value;
|
|
23
24
|
}
|
|
24
25
|
return type.fieldWrapper.wrapField(value);
|