@bufbuild/protobuf 2.0.0-beta.2 → 2.0.0-beta.3
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/README.md +15 -13
- package/dist/cjs/clone.js +1 -2
- package/dist/cjs/codegenv1/boot.js +2 -3
- package/dist/cjs/codegenv1/embed.js +3 -4
- package/dist/cjs/codegenv1/enum.d.ts +2 -2
- package/dist/cjs/codegenv1/enum.js +2 -3
- package/dist/cjs/codegenv1/extension.d.ts +2 -2
- package/dist/cjs/codegenv1/extension.js +1 -2
- package/dist/cjs/codegenv1/file.js +1 -2
- package/dist/cjs/codegenv1/message.d.ts +2 -2
- package/dist/cjs/codegenv1/message.js +1 -2
- package/dist/cjs/codegenv1/restore-json-names.js +1 -2
- package/dist/cjs/codegenv1/scalar.js +2 -3
- package/dist/cjs/codegenv1/service.d.ts +2 -2
- package/dist/cjs/codegenv1/service.js +1 -2
- package/dist/cjs/codegenv1/symbols.d.ts +5 -5
- package/dist/cjs/codegenv1/symbols.js +5 -5
- package/dist/cjs/codegenv1/types.d.ts +9 -7
- package/dist/cjs/create.js +5 -4
- package/dist/cjs/descriptors.d.ts +4 -0
- package/dist/cjs/equals.js +1 -2
- package/dist/cjs/extensions.js +7 -8
- package/dist/cjs/fields.js +2 -3
- package/dist/cjs/from-binary.js +3 -4
- package/dist/cjs/from-json.js +6 -7
- package/dist/cjs/is-message.js +1 -2
- package/dist/cjs/reflect/error.js +2 -2
- package/dist/cjs/reflect/guard.js +5 -6
- package/dist/cjs/reflect/names.js +2 -3
- package/dist/cjs/reflect/nested-types.js +2 -3
- package/dist/cjs/reflect/reflect-check.js +4 -5
- package/dist/cjs/reflect/reflect.js +3 -4
- package/dist/cjs/reflect/scalar.js +3 -4
- package/dist/cjs/reflect/unsafe.js +7 -7
- package/dist/cjs/registry.js +15 -9
- package/dist/cjs/to-binary.js +2 -3
- package/dist/cjs/to-json.js +5 -6
- package/dist/cjs/types.d.ts +8 -8
- package/dist/cjs/wire/base64-encoding.js +2 -3
- package/dist/cjs/wire/size-delimited.js +3 -4
- package/dist/cjs/wire/text-encoding.js +2 -3
- package/dist/cjs/wire/text-format.js +2 -3
- package/dist/cjs/wire/varint.js +7 -8
- package/dist/cjs/wkt/any.js +4 -5
- package/dist/cjs/wkt/gen/google/protobuf/any_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.d.ts +5 -5
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +7 -7
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.d.ts +52 -52
- package/dist/cjs/wkt/gen/google/protobuf/duration_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/struct_pb.d.ts +6 -6
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.d.ts +10 -10
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.d.ts +11 -11
- package/dist/cjs/wkt/timestamp.js +5 -6
- package/dist/cjs/wkt/wrappers.js +2 -3
- package/dist/esm/codegenv1/enum.d.ts +2 -2
- package/dist/esm/codegenv1/extension.d.ts +2 -2
- package/dist/esm/codegenv1/message.d.ts +2 -2
- package/dist/esm/codegenv1/service.d.ts +2 -2
- package/dist/esm/codegenv1/symbols.d.ts +5 -5
- package/dist/esm/codegenv1/symbols.js +5 -5
- package/dist/esm/codegenv1/types.d.ts +9 -7
- package/dist/esm/create.js +4 -2
- package/dist/esm/descriptors.d.ts +4 -0
- package/dist/esm/registry.js +11 -5
- package/dist/esm/to-json.js +2 -2
- package/dist/esm/types.d.ts +8 -8
- package/dist/esm/wkt/gen/google/protobuf/any_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/api_pb.d.ts +5 -5
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +7 -7
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.d.ts +52 -52
- package/dist/esm/wkt/gen/google/protobuf/duration_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/struct_pb.d.ts +6 -6
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/type_pb.d.ts +10 -10
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.d.ts +11 -11
- package/package.json +8 -4
package/dist/cjs/from-json.js
CHANGED
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.fromJsonString = fromJsonString;
|
|
17
|
+
exports.mergeFromJsonString = mergeFromJsonString;
|
|
18
|
+
exports.fromJson = fromJson;
|
|
19
|
+
exports.mergeFromJson = mergeFromJson;
|
|
20
|
+
exports.enumFromJson = enumFromJson;
|
|
21
|
+
exports.isEnumJson = isEnumJson;
|
|
17
22
|
/* eslint-disable no-case-declarations,@typescript-eslint/restrict-template-expressions */
|
|
18
23
|
const descriptors_js_1 = require("./descriptors.js");
|
|
19
24
|
const proto_int64_js_1 = require("./proto-int64.js");
|
|
@@ -38,7 +43,6 @@ function makeReadOptions(options) {
|
|
|
38
43
|
function fromJsonString(schema, json, options) {
|
|
39
44
|
return fromJson(schema, parseJsonString(json, schema.typeName), options);
|
|
40
45
|
}
|
|
41
|
-
exports.fromJsonString = fromJsonString;
|
|
42
46
|
/**
|
|
43
47
|
* Parse a message from a JSON string, merging fields.
|
|
44
48
|
*
|
|
@@ -51,7 +55,6 @@ exports.fromJsonString = fromJsonString;
|
|
|
51
55
|
function mergeFromJsonString(schema, target, json, options) {
|
|
52
56
|
return mergeFromJson(schema, target, parseJsonString(json, schema.typeName), options);
|
|
53
57
|
}
|
|
54
|
-
exports.mergeFromJsonString = mergeFromJsonString;
|
|
55
58
|
/**
|
|
56
59
|
* Parse a message from a JSON value.
|
|
57
60
|
*/
|
|
@@ -71,7 +74,6 @@ function fromJson(schema, json, options) {
|
|
|
71
74
|
}
|
|
72
75
|
return msg.message;
|
|
73
76
|
}
|
|
74
|
-
exports.fromJson = fromJson;
|
|
75
77
|
/**
|
|
76
78
|
* Parse a message from a JSON value, merging fields.
|
|
77
79
|
*
|
|
@@ -96,7 +98,6 @@ function mergeFromJson(schema, target, json, options) {
|
|
|
96
98
|
}
|
|
97
99
|
return target;
|
|
98
100
|
}
|
|
99
|
-
exports.mergeFromJson = mergeFromJson;
|
|
100
101
|
/**
|
|
101
102
|
* Parses an enum value from JSON.
|
|
102
103
|
*/
|
|
@@ -107,14 +108,12 @@ function enumFromJson(descEnum, json) {
|
|
|
107
108
|
}
|
|
108
109
|
return val;
|
|
109
110
|
}
|
|
110
|
-
exports.enumFromJson = enumFromJson;
|
|
111
111
|
/**
|
|
112
112
|
* Is the given value a JSON enum value?
|
|
113
113
|
*/
|
|
114
114
|
function isEnumJson(descEnum, value) {
|
|
115
115
|
return undefined !== descEnum.values.find((v) => v.name === value);
|
|
116
116
|
}
|
|
117
|
-
exports.isEnumJson = isEnumJson;
|
|
118
117
|
function readMessage(msg, json, opts) {
|
|
119
118
|
var _a;
|
|
120
119
|
if (tryWktFromJson(msg, json, opts)) {
|
package/dist/cjs/is-message.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.isMessage =
|
|
16
|
+
exports.isMessage = isMessage;
|
|
17
17
|
/**
|
|
18
18
|
* Determine whether the given `arg` is a message.
|
|
19
19
|
* If `desc` is set, determine whether `arg` is this specific message.
|
|
@@ -31,4 +31,3 @@ function isMessage(arg, schema) {
|
|
|
31
31
|
}
|
|
32
32
|
return schema.typeName === arg.$typeName;
|
|
33
33
|
}
|
|
34
|
-
exports.isMessage = isMessage;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.FieldError = void 0;
|
|
17
|
+
exports.isFieldError = isFieldError;
|
|
17
18
|
const errorNames = [
|
|
18
19
|
"FieldValueInvalidError",
|
|
19
20
|
"FieldListRangeError",
|
|
@@ -33,4 +34,3 @@ function isFieldError(arg) {
|
|
|
33
34
|
"field" in arg &&
|
|
34
35
|
typeof arg.field == "function");
|
|
35
36
|
}
|
|
36
|
-
exports.isFieldError = isFieldError;
|
|
@@ -13,12 +13,15 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.isObject = isObject;
|
|
17
|
+
exports.isOneofADT = isOneofADT;
|
|
18
|
+
exports.isReflectList = isReflectList;
|
|
19
|
+
exports.isReflectMap = isReflectMap;
|
|
20
|
+
exports.isReflectMessage = isReflectMessage;
|
|
17
21
|
const unsafe_js_1 = require("./unsafe.js");
|
|
18
22
|
function isObject(arg) {
|
|
19
23
|
return arg !== null && typeof arg == "object" && !Array.isArray(arg);
|
|
20
24
|
}
|
|
21
|
-
exports.isObject = isObject;
|
|
22
25
|
function isOneofADT(arg) {
|
|
23
26
|
return (arg !== null &&
|
|
24
27
|
typeof arg == "object" &&
|
|
@@ -27,7 +30,6 @@ function isOneofADT(arg) {
|
|
|
27
30
|
(arg.case === undefined &&
|
|
28
31
|
(!("value" in arg) || arg.value === undefined))));
|
|
29
32
|
}
|
|
30
|
-
exports.isOneofADT = isOneofADT;
|
|
31
33
|
function isReflectList(arg, field) {
|
|
32
34
|
var _a, _b, _c, _d;
|
|
33
35
|
if (isObject(arg) &&
|
|
@@ -46,7 +48,6 @@ function isReflectList(arg, field) {
|
|
|
46
48
|
}
|
|
47
49
|
return false;
|
|
48
50
|
}
|
|
49
|
-
exports.isReflectList = isReflectList;
|
|
50
51
|
function isReflectMap(arg, field) {
|
|
51
52
|
var _a, _b, _c, _d;
|
|
52
53
|
if (isObject(arg) &&
|
|
@@ -66,7 +67,6 @@ function isReflectMap(arg, field) {
|
|
|
66
67
|
}
|
|
67
68
|
return false;
|
|
68
69
|
}
|
|
69
|
-
exports.isReflectMap = isReflectMap;
|
|
70
70
|
function isReflectMessage(arg, messageDesc) {
|
|
71
71
|
return (isObject(arg) &&
|
|
72
72
|
unsafe_js_1.unsafeLocal in arg &&
|
|
@@ -75,4 +75,3 @@ function isReflectMessage(arg, messageDesc) {
|
|
|
75
75
|
arg.desc.kind === "message" &&
|
|
76
76
|
(messageDesc === undefined || arg.desc.typeName == messageDesc.typeName));
|
|
77
77
|
}
|
|
78
|
-
exports.isReflectMessage = isReflectMessage;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.protoCamelCase = protoCamelCase;
|
|
17
|
+
exports.safeObjectProperty = safeObjectProperty;
|
|
17
18
|
/**
|
|
18
19
|
* Converts snake_case to protoCamelCase according to the convention
|
|
19
20
|
* used by protoc to convert a field name to a JSON name.
|
|
@@ -51,7 +52,6 @@ function protoCamelCase(snakeCase) {
|
|
|
51
52
|
}
|
|
52
53
|
return b.join("");
|
|
53
54
|
}
|
|
54
|
-
exports.protoCamelCase = protoCamelCase;
|
|
55
55
|
/**
|
|
56
56
|
* Names that cannot be used for object properties because they are reserved
|
|
57
57
|
* by built-in JavaScript properties.
|
|
@@ -71,4 +71,3 @@ const reservedObjectProperties = new Set([
|
|
|
71
71
|
function safeObjectProperty(name) {
|
|
72
72
|
return reservedObjectProperties.has(name) ? name + "$" : name;
|
|
73
73
|
}
|
|
74
|
-
exports.safeObjectProperty = safeObjectProperty;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.nestedTypes = nestedTypes;
|
|
17
|
+
exports.parentTypes = parentTypes;
|
|
17
18
|
/**
|
|
18
19
|
* Iterate over all types - enumerations, extensions, services, messages -
|
|
19
20
|
* and enumerations, extensions and messages nested in messages.
|
|
@@ -39,7 +40,6 @@ function* nestedTypes(desc) {
|
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
exports.nestedTypes = nestedTypes;
|
|
43
43
|
/**
|
|
44
44
|
* Returns the ancestors of a given Protobuf element, up to the file.
|
|
45
45
|
*/
|
|
@@ -52,7 +52,6 @@ function parentTypes(desc) {
|
|
|
52
52
|
}
|
|
53
53
|
return parents;
|
|
54
54
|
}
|
|
55
|
-
exports.parentTypes = parentTypes;
|
|
56
55
|
function parent(desc) {
|
|
57
56
|
var _a;
|
|
58
57
|
switch (desc.kind) {
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.checkField = checkField;
|
|
17
|
+
exports.checkListItem = checkListItem;
|
|
18
|
+
exports.checkMapEntry = checkMapEntry;
|
|
19
|
+
exports.formatVal = formatVal;
|
|
17
20
|
const descriptors_js_1 = require("../descriptors.js");
|
|
18
21
|
const is_message_js_1 = require("../is-message.js");
|
|
19
22
|
const error_js_1 = require("./error.js");
|
|
@@ -47,7 +50,6 @@ function checkField(field, value) {
|
|
|
47
50
|
}
|
|
48
51
|
return new error_js_1.FieldError(field, reason);
|
|
49
52
|
}
|
|
50
|
-
exports.checkField = checkField;
|
|
51
53
|
/**
|
|
52
54
|
* Check whether the given list item is valid for the reflect API.
|
|
53
55
|
*/
|
|
@@ -58,7 +60,6 @@ function checkListItem(field, index, value) {
|
|
|
58
60
|
}
|
|
59
61
|
return undefined;
|
|
60
62
|
}
|
|
61
|
-
exports.checkListItem = checkListItem;
|
|
62
63
|
/**
|
|
63
64
|
* Check whether the given map key and value are valid for the reflect API.
|
|
64
65
|
*/
|
|
@@ -73,7 +74,6 @@ function checkMapEntry(field, key, value) {
|
|
|
73
74
|
}
|
|
74
75
|
return undefined;
|
|
75
76
|
}
|
|
76
|
-
exports.checkMapEntry = checkMapEntry;
|
|
77
77
|
function checkSingular(field, value) {
|
|
78
78
|
if (field.scalar !== undefined) {
|
|
79
79
|
return checkScalarValue(value, field.scalar);
|
|
@@ -213,7 +213,6 @@ function formatVal(val) {
|
|
|
213
213
|
return typeof val;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
exports.formatVal = formatVal;
|
|
217
216
|
function formatReflectMessage(desc) {
|
|
218
217
|
return `ReflectMessage (${desc.typeName})`;
|
|
219
218
|
}
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.reflect = reflect;
|
|
17
|
+
exports.reflectList = reflectList;
|
|
18
|
+
exports.reflectMap = reflectMap;
|
|
17
19
|
const descriptors_js_1 = require("../descriptors.js");
|
|
18
20
|
const reflect_check_js_1 = require("./reflect-check.js");
|
|
19
21
|
const error_js_1 = require("./error.js");
|
|
@@ -37,7 +39,6 @@ function reflect(messageDesc, message,
|
|
|
37
39
|
check = true) {
|
|
38
40
|
return new ReflectMessageImpl(messageDesc, message, check);
|
|
39
41
|
}
|
|
40
|
-
exports.reflect = reflect;
|
|
41
42
|
class ReflectMessageImpl {
|
|
42
43
|
get sortedFields() {
|
|
43
44
|
var _a;
|
|
@@ -147,7 +148,6 @@ function reflectList(field, unsafeInput,
|
|
|
147
148
|
check = true) {
|
|
148
149
|
return new ReflectListImpl(field, unsafeInput !== null && unsafeInput !== void 0 ? unsafeInput : [], check);
|
|
149
150
|
}
|
|
150
|
-
exports.reflectList = reflectList;
|
|
151
151
|
class ReflectListImpl {
|
|
152
152
|
field() {
|
|
153
153
|
return this._field;
|
|
@@ -222,7 +222,6 @@ function reflectMap(field, unsafeInput,
|
|
|
222
222
|
check = true) {
|
|
223
223
|
return new ReflectMapImpl(field, unsafeInput, check);
|
|
224
224
|
}
|
|
225
|
-
exports.reflectMap = reflectMap;
|
|
226
225
|
class ReflectMapImpl {
|
|
227
226
|
constructor(field, unsafeInput, check = true) {
|
|
228
227
|
this.obj = this[unsafe_js_1.unsafeLocal] = unsafeInput !== null && unsafeInput !== void 0 ? unsafeInput : {};
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.scalarEquals = scalarEquals;
|
|
17
|
+
exports.scalarZeroValue = scalarZeroValue;
|
|
18
|
+
exports.isScalarZeroValue = isScalarZeroValue;
|
|
17
19
|
const proto_int64_js_1 = require("../proto-int64.js");
|
|
18
20
|
const descriptors_js_1 = require("../descriptors.js");
|
|
19
21
|
/**
|
|
@@ -54,7 +56,6 @@ function scalarEquals(type, a, b) {
|
|
|
54
56
|
// BYTES and 64-bit integers is not equal.
|
|
55
57
|
return false;
|
|
56
58
|
}
|
|
57
|
-
exports.scalarEquals = scalarEquals;
|
|
58
59
|
/**
|
|
59
60
|
* Returns the zero value for the given scalar type.
|
|
60
61
|
*/
|
|
@@ -81,7 +82,6 @@ function scalarZeroValue(type, longAsString) {
|
|
|
81
82
|
return new Uint8Array(0);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
exports.scalarZeroValue = scalarZeroValue;
|
|
85
85
|
/**
|
|
86
86
|
* Returns true for a zero-value. For example, an integer has the zero-value `0`,
|
|
87
87
|
* a boolean is `false`, a string is `""`, and bytes is an empty Uint8Array.
|
|
@@ -101,4 +101,3 @@ function isScalarZeroValue(type, value) {
|
|
|
101
101
|
return value == 0; // Loose comparison matches 0n, 0 and "0"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
exports.isScalarZeroValue = isScalarZeroValue;
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.unsafeLocal = void 0;
|
|
17
|
+
exports.unsafeOneofCase = unsafeOneofCase;
|
|
18
|
+
exports.unsafeIsSet = unsafeIsSet;
|
|
19
|
+
exports.unsafeIsSetExplicit = unsafeIsSetExplicit;
|
|
20
|
+
exports.unsafeGet = unsafeGet;
|
|
21
|
+
exports.unsafeSet = unsafeSet;
|
|
22
|
+
exports.unsafeClear = unsafeClear;
|
|
17
23
|
const scalar_js_1 = require("./scalar.js");
|
|
18
24
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
|
|
19
25
|
const IMPLICIT = 2;
|
|
@@ -31,7 +37,6 @@ oneof) {
|
|
|
31
37
|
}
|
|
32
38
|
return oneof.fields.find((f) => f.localName === c);
|
|
33
39
|
}
|
|
34
|
-
exports.unsafeOneofCase = unsafeOneofCase;
|
|
35
40
|
/**
|
|
36
41
|
* Returns true if the field is set.
|
|
37
42
|
*
|
|
@@ -62,7 +67,6 @@ field) {
|
|
|
62
67
|
}
|
|
63
68
|
throw new Error("message field with implicit presence");
|
|
64
69
|
}
|
|
65
|
-
exports.unsafeIsSet = unsafeIsSet;
|
|
66
70
|
/**
|
|
67
71
|
* Returns true if the field is set, but only for singular fields with explicit
|
|
68
72
|
* presence (proto2).
|
|
@@ -73,7 +77,6 @@ function unsafeIsSetExplicit(target, localName) {
|
|
|
73
77
|
return (Object.prototype.hasOwnProperty.call(target, localName) &&
|
|
74
78
|
target[localName] !== undefined);
|
|
75
79
|
}
|
|
76
|
-
exports.unsafeIsSetExplicit = unsafeIsSetExplicit;
|
|
77
80
|
/**
|
|
78
81
|
* Return a field value, respecting oneof groups.
|
|
79
82
|
*
|
|
@@ -89,7 +92,6 @@ function unsafeGet(target, field) {
|
|
|
89
92
|
}
|
|
90
93
|
return target[field.localName];
|
|
91
94
|
}
|
|
92
|
-
exports.unsafeGet = unsafeGet;
|
|
93
95
|
/**
|
|
94
96
|
* Set a field value, respecting oneof groups.
|
|
95
97
|
*
|
|
@@ -106,7 +108,6 @@ function unsafeSet(target, field, value) {
|
|
|
106
108
|
target[field.localName] = value;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
exports.unsafeSet = unsafeSet;
|
|
110
111
|
/**
|
|
111
112
|
* Resets the field, so that unsafeIsSet() will return false.
|
|
112
113
|
*
|
|
@@ -145,4 +146,3 @@ field) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
exports.unsafeClear = unsafeClear;
|
package/dist/cjs/registry.js
CHANGED
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.maximumEdition = exports.minimumEdition =
|
|
16
|
+
exports.maximumEdition = exports.minimumEdition = void 0;
|
|
17
|
+
exports.createRegistry = createRegistry;
|
|
18
|
+
exports.createMutableRegistry = createMutableRegistry;
|
|
19
|
+
exports.createFileRegistry = createFileRegistry;
|
|
17
20
|
const descriptors_js_1 = require("./descriptors.js");
|
|
18
21
|
const text_format_js_1 = require("./wire/text-format.js");
|
|
19
22
|
const nested_types_js_1 = require("./reflect/nested-types.js");
|
|
@@ -33,7 +36,6 @@ const names_js_1 = require("./reflect/names.js");
|
|
|
33
36
|
function createRegistry(...input) {
|
|
34
37
|
return initBaseRegistry(input);
|
|
35
38
|
}
|
|
36
|
-
exports.createRegistry = createRegistry;
|
|
37
39
|
/**
|
|
38
40
|
* Create a registry that allows adding and removing descriptors.
|
|
39
41
|
*/
|
|
@@ -47,9 +49,11 @@ function createMutableRegistry(...input) {
|
|
|
47
49
|
reg.types.delete(desc.typeName);
|
|
48
50
|
} });
|
|
49
51
|
}
|
|
50
|
-
exports.createMutableRegistry = createMutableRegistry;
|
|
51
52
|
function createFileRegistry(...args) {
|
|
52
53
|
const registry = createBaseRegistry();
|
|
54
|
+
if (!args.length) {
|
|
55
|
+
return registry;
|
|
56
|
+
}
|
|
53
57
|
if ("$typeName" in args[0] &&
|
|
54
58
|
args[0].$typeName == "google.protobuf.FileDescriptorSet") {
|
|
55
59
|
for (const file of args[0].file) {
|
|
@@ -98,7 +102,6 @@ function createFileRegistry(...args) {
|
|
|
98
102
|
}
|
|
99
103
|
return registry;
|
|
100
104
|
}
|
|
101
|
-
exports.createFileRegistry = createFileRegistry;
|
|
102
105
|
/**
|
|
103
106
|
* @private
|
|
104
107
|
*/
|
|
@@ -382,6 +385,7 @@ function addEnum(proto, file, parent, reg) {
|
|
|
382
385
|
open: true,
|
|
383
386
|
name: proto.name,
|
|
384
387
|
typeName: makeTypeName(proto, parent, file),
|
|
388
|
+
value: {},
|
|
385
389
|
values: [],
|
|
386
390
|
sharedPrefix,
|
|
387
391
|
toString() {
|
|
@@ -393,18 +397,20 @@ function addEnum(proto, file, parent, reg) {
|
|
|
393
397
|
proto.value.forEach((proto) => {
|
|
394
398
|
var _a, _b;
|
|
395
399
|
const name = proto.name;
|
|
396
|
-
desc.values.push({
|
|
400
|
+
desc.values.push((desc.value[proto.number] = {
|
|
397
401
|
kind: "enum_value",
|
|
398
402
|
proto,
|
|
399
403
|
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
400
404
|
parent: desc,
|
|
401
|
-
name
|
|
402
|
-
localName: (0, names_js_1.safeObjectProperty)(sharedPrefix == undefined
|
|
405
|
+
name,
|
|
406
|
+
localName: (0, names_js_1.safeObjectProperty)(sharedPrefix == undefined
|
|
407
|
+
? name
|
|
408
|
+
: name.substring(sharedPrefix.length)),
|
|
403
409
|
number: proto.number,
|
|
404
410
|
toString() {
|
|
405
|
-
return `enum value ${desc.typeName}.${
|
|
411
|
+
return `enum value ${desc.typeName}.${name}`;
|
|
406
412
|
},
|
|
407
|
-
});
|
|
413
|
+
}));
|
|
408
414
|
});
|
|
409
415
|
((_c = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _c !== void 0 ? _c : file.enums).push(desc);
|
|
410
416
|
}
|
package/dist/cjs/to-binary.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.toBinary = toBinary;
|
|
17
|
+
exports.writeField = writeField;
|
|
17
18
|
const reflect_js_1 = require("./reflect/reflect.js");
|
|
18
19
|
const binary_encoding_js_1 = require("./wire/binary-encoding.js");
|
|
19
20
|
const descriptors_js_1 = require("./descriptors.js");
|
|
@@ -29,7 +30,6 @@ function makeWriteOptions(options) {
|
|
|
29
30
|
function toBinary(schema, message, options) {
|
|
30
31
|
return writeFields(new binary_encoding_js_1.BinaryWriter(), makeWriteOptions(options), (0, reflect_js_1.reflect)(schema, message)).finish();
|
|
31
32
|
}
|
|
32
|
-
exports.toBinary = toBinary;
|
|
33
33
|
function writeFields(writer, opts, msg) {
|
|
34
34
|
var _a;
|
|
35
35
|
for (const f of msg.sortedFields) {
|
|
@@ -71,7 +71,6 @@ function writeField(writer, opts, msg, field) {
|
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
exports.writeField = writeField;
|
|
75
74
|
function writeScalar(writer, scalarType, fieldNo, value) {
|
|
76
75
|
writeScalarValue(writer.tag(fieldNo, writeTypeOfScalar(scalarType)), scalarType, value);
|
|
77
76
|
}
|
package/dist/cjs/to-json.js
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.toJson = toJson;
|
|
17
|
+
exports.toJsonString = toJsonString;
|
|
18
|
+
exports.enumToJson = enumToJson;
|
|
17
19
|
const descriptors_js_1 = require("./descriptors.js");
|
|
18
20
|
const names_js_1 = require("./reflect/names.js");
|
|
19
21
|
const reflect_js_1 = require("./reflect/reflect.js");
|
|
@@ -43,7 +45,6 @@ function makeWriteOptions(options) {
|
|
|
43
45
|
function toJson(schema, message, options) {
|
|
44
46
|
return reflectToJson((0, reflect_js_1.reflect)(schema, message), makeWriteOptions(options));
|
|
45
47
|
}
|
|
46
|
-
exports.toJson = toJson;
|
|
47
48
|
/**
|
|
48
49
|
* Serialize the message to a JSON string.
|
|
49
50
|
*/
|
|
@@ -52,7 +53,6 @@ function toJsonString(schema, message, options) {
|
|
|
52
53
|
const jsonValue = toJson(schema, message, options);
|
|
53
54
|
return JSON.stringify(jsonValue, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);
|
|
54
55
|
}
|
|
55
|
-
exports.toJsonString = toJsonString;
|
|
56
56
|
/**
|
|
57
57
|
* Serialize a single enum value to JSON.
|
|
58
58
|
*/
|
|
@@ -61,13 +61,12 @@ function enumToJson(descEnum, value) {
|
|
|
61
61
|
if (descEnum.typeName == "google.protobuf.NullValue") {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
const name = (_a = descEnum.
|
|
64
|
+
const name = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.name;
|
|
65
65
|
if (name === undefined) {
|
|
66
66
|
throw new Error(`${String(value)} is not a value in ${descEnum.toString()}`);
|
|
67
67
|
}
|
|
68
68
|
return name;
|
|
69
69
|
}
|
|
70
|
-
exports.enumToJson = enumToJson;
|
|
71
70
|
function reflectToJson(msg, opts) {
|
|
72
71
|
var _a;
|
|
73
72
|
const wktJson = tryWktToJson(msg, opts);
|
|
@@ -180,7 +179,7 @@ function enumToJsonInternal(desc, value, enumAsInteger) {
|
|
|
180
179
|
if (enumAsInteger) {
|
|
181
180
|
return value;
|
|
182
181
|
}
|
|
183
|
-
const val = desc.
|
|
182
|
+
const val = desc.value[value];
|
|
184
183
|
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
|
|
185
184
|
}
|
|
186
185
|
function scalarToJson(field, value) {
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GenEnum, GenExtension, GenMessage } from "./codegenv1/types.js";
|
|
2
2
|
import type { DescEnum, DescExtension, DescMessage } from "./descriptors.js";
|
|
3
3
|
import type { OneofADT } from "./reflect/guard.js";
|
|
4
4
|
import type { WireType } from "./wire/index.js";
|
|
@@ -19,32 +19,32 @@ export type Message<TypeName extends string = string> = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Extract the message type from a message descriptor.
|
|
21
21
|
*/
|
|
22
|
-
export type MessageShape<Desc extends DescMessage> = Desc extends
|
|
22
|
+
export type MessageShape<Desc extends DescMessage> = Desc extends GenMessage<infer RuntimeShape> ? RuntimeShape : Message;
|
|
23
23
|
/**
|
|
24
24
|
* Extract the message JSON type from a message descriptor.
|
|
25
25
|
*/
|
|
26
|
-
export type MessageJsonType<Desc extends DescMessage> = Desc extends
|
|
26
|
+
export type MessageJsonType<Desc extends DescMessage> = Desc extends GenMessage<Message, infer JsonType> ? JsonType : JsonValue;
|
|
27
27
|
/**
|
|
28
28
|
* Extract the init type from a message descriptor.
|
|
29
29
|
* The init type is accepted by the function create().
|
|
30
30
|
*/
|
|
31
|
-
export type MessageInitShape<Desc extends DescMessage> = Desc extends
|
|
31
|
+
export type MessageInitShape<Desc extends DescMessage> = Desc extends GenMessage<infer RuntimeShape> ? RuntimeShape | MessageInit<RuntimeShape> : Record<string, unknown>;
|
|
32
32
|
/**
|
|
33
33
|
* Extract the enum type of from an enum descriptor.
|
|
34
34
|
*/
|
|
35
|
-
export type EnumShape<Desc extends DescEnum> = Desc extends
|
|
35
|
+
export type EnumShape<Desc extends DescEnum> = Desc extends GenEnum<infer RuntimeShape> ? RuntimeShape : number;
|
|
36
36
|
/**
|
|
37
37
|
* Extract the enum JSON type from a enum descriptor.
|
|
38
38
|
*/
|
|
39
|
-
export type EnumJsonType<Desc extends DescEnum> = Desc extends
|
|
39
|
+
export type EnumJsonType<Desc extends DescEnum> = Desc extends GenEnum<number, infer JsonType> ? JsonType : string | null;
|
|
40
40
|
/**
|
|
41
41
|
* Extract the value type from an extension descriptor.
|
|
42
42
|
*/
|
|
43
|
-
export type ExtensionValueShape<Desc extends DescExtension> = Desc extends
|
|
43
|
+
export type ExtensionValueShape<Desc extends DescExtension> = Desc extends GenExtension<Message, infer RuntimeShape> ? RuntimeShape : unknown;
|
|
44
44
|
/**
|
|
45
45
|
* Extract the type of the extended message from an extension descriptor.
|
|
46
46
|
*/
|
|
47
|
-
export type Extendee<Desc extends DescExtension> = Desc extends
|
|
47
|
+
export type Extendee<Desc extends DescExtension> = Desc extends GenExtension<infer Extendee> ? Extendee : Message;
|
|
48
48
|
/**
|
|
49
49
|
* Unknown fields are fields that were not recognized during parsing, or
|
|
50
50
|
* extension.
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.base64Decode = base64Decode;
|
|
17
|
+
exports.base64Encode = base64Encode;
|
|
17
18
|
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
|
|
18
19
|
/**
|
|
19
20
|
* Decodes a base64 string to a byte array.
|
|
@@ -80,7 +81,6 @@ function base64Decode(base64Str) {
|
|
|
80
81
|
throw Error("invalid base64 string");
|
|
81
82
|
return bytes.subarray(0, bytePos);
|
|
82
83
|
}
|
|
83
|
-
exports.base64Decode = base64Decode;
|
|
84
84
|
/**
|
|
85
85
|
* Encode a byte array to a base64 string.
|
|
86
86
|
*
|
|
@@ -128,7 +128,6 @@ function base64Encode(bytes, encoding = "std") {
|
|
|
128
128
|
}
|
|
129
129
|
return base64;
|
|
130
130
|
}
|
|
131
|
-
exports.base64Encode = base64Encode;
|
|
132
131
|
// lookup table from base64 character to byte
|
|
133
132
|
let encodeTableStd;
|
|
134
133
|
let encodeTableUrl;
|
|
@@ -33,7 +33,9 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
33
33
|
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.sizeDelimitedEncode = sizeDelimitedEncode;
|
|
37
|
+
exports.sizeDelimitedDecodeStream = sizeDelimitedDecodeStream;
|
|
38
|
+
exports.sizeDelimitedPeek = sizeDelimitedPeek;
|
|
37
39
|
const to_binary_js_1 = require("../to-binary.js");
|
|
38
40
|
const binary_encoding_js_1 = require("./binary-encoding.js");
|
|
39
41
|
const from_binary_js_1 = require("../from-binary.js");
|
|
@@ -51,7 +53,6 @@ function sizeDelimitedEncode(messageDesc, message, options) {
|
|
|
51
53
|
writer.bytes((0, to_binary_js_1.toBinary)(messageDesc, message, options));
|
|
52
54
|
return writer.finish();
|
|
53
55
|
}
|
|
54
|
-
exports.sizeDelimitedEncode = sizeDelimitedEncode;
|
|
55
56
|
/**
|
|
56
57
|
* Parse a stream of size-delimited messages.
|
|
57
58
|
*
|
|
@@ -105,7 +106,6 @@ function sizeDelimitedDecodeStream(messageDesc, iterable, options) {
|
|
|
105
106
|
}
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
|
-
exports.sizeDelimitedDecodeStream = sizeDelimitedDecodeStream;
|
|
109
109
|
/**
|
|
110
110
|
* Decodes the size from the given size-delimited message, which may be
|
|
111
111
|
* incomplete.
|
|
@@ -151,4 +151,3 @@ function sizeDelimitedPeek(data) {
|
|
|
151
151
|
}
|
|
152
152
|
throw new Error("invalid varint");
|
|
153
153
|
}
|
|
154
|
-
exports.sizeDelimitedPeek = sizeDelimitedPeek;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.configureTextEncoding = configureTextEncoding;
|
|
17
|
+
exports.getTextEncoding = getTextEncoding;
|
|
17
18
|
const symbol = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
18
19
|
/**
|
|
19
20
|
* Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to
|
|
@@ -27,7 +28,6 @@ const symbol = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
|
27
28
|
function configureTextEncoding(textEncoding) {
|
|
28
29
|
globalThis[symbol] = textEncoding;
|
|
29
30
|
}
|
|
30
|
-
exports.configureTextEncoding = configureTextEncoding;
|
|
31
31
|
function getTextEncoding() {
|
|
32
32
|
if (globalThis[symbol] == undefined) {
|
|
33
33
|
const te = new globalThis.TextEncoder();
|
|
@@ -52,4 +52,3 @@ function getTextEncoding() {
|
|
|
52
52
|
}
|
|
53
53
|
return globalThis[symbol];
|
|
54
54
|
}
|
|
55
|
-
exports.getTextEncoding = getTextEncoding;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.parseTextFormatEnumValue = parseTextFormatEnumValue;
|
|
17
|
+
exports.parseTextFormatScalarValue = parseTextFormatScalarValue;
|
|
17
18
|
const descriptors_js_1 = require("../descriptors.js");
|
|
18
19
|
const proto_int64_js_1 = require("../proto-int64.js");
|
|
19
20
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
@@ -29,7 +30,6 @@ function parseTextFormatEnumValue(descEnum, value) {
|
|
|
29
30
|
}
|
|
30
31
|
return enumValue.number;
|
|
31
32
|
}
|
|
32
|
-
exports.parseTextFormatEnumValue = parseTextFormatEnumValue;
|
|
33
33
|
/**
|
|
34
34
|
* Parse a scalar value from the Protobuf text format.
|
|
35
35
|
*
|
|
@@ -75,7 +75,6 @@ function parseTextFormatScalarValue(type, value) {
|
|
|
75
75
|
return parseInt(value, 10);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
exports.parseTextFormatScalarValue = parseTextFormatScalarValue;
|
|
79
78
|
/**
|
|
80
79
|
* Parses a text-encoded default value (proto2) of a BYTES field.
|
|
81
80
|
*/
|