protobufjs
Advanced tools
Comparing version
/*! | ||
* protobuf.js v8.1.4-experimental (c) 2016, daniel wirtz | ||
* compiled tue, 13 may 2025 18:22:04 utc | ||
* protobuf.js v8.1.5-experimental (c) 2016, daniel wirtz | ||
* compiled tue, 27 may 2025 20:34:38 utc | ||
* licensed under the bsd-3-clause license | ||
@@ -5,0 +5,0 @@ * see: https://github.com/dcodeio/protobuf.js for details |
@@ -38,5 +38,24 @@ "use strict"; | ||
* @property {string} [syntax="proto2"] Syntax | ||
* @property {IEdition} [edition] Edition | ||
*/ | ||
/** | ||
* Values of the Edition enum. | ||
* @typedef IEdition | ||
* @type {number} | ||
* @property {number} EDITION_UNKNOWN=0 | ||
* @property {number} EDITION_LEGACY=900 | ||
* @property {number} EDITION_PROTO2=998 | ||
* @property {number} EDITION_PROTO3=999 | ||
* @property {number} EDITION_2023=1000 | ||
* @property {number} EDITION_2024=1001 | ||
* @property {number} EDITION_1_TEST_ONLY=1 | ||
* @property {number} EDITION_2_TEST_ONLY=2 | ||
* @property {number} EDITION_99997_TEST_ONLY=99997 | ||
* @property {number} EDITION_99998_TEST_ONLY=99998 | ||
* @property {number} EDITION_99998_TEST_ONLY=99999 | ||
* @property {number} EDITION_MAX=2147483647 | ||
*/ | ||
/** | ||
* Properties of a FileOptions message. | ||
@@ -89,2 +108,3 @@ * @interface IFileOptions | ||
filePackage = root.define(fileDescriptor["package"]); | ||
var edition = editionFromDescriptor(fileDescriptor); | ||
if (fileDescriptor.name && fileDescriptor.name.length) | ||
@@ -94,12 +114,12 @@ root.files.push(filePackage.filename = fileDescriptor.name); | ||
for (i = 0; i < fileDescriptor.messageType.length; ++i) | ||
filePackage.add(Type.fromDescriptor(fileDescriptor.messageType[i], fileDescriptor.syntax)); | ||
filePackage.add(Type.fromDescriptor(fileDescriptor.messageType[i], edition)); | ||
if (fileDescriptor.enumType) | ||
for (i = 0; i < fileDescriptor.enumType.length; ++i) | ||
filePackage.add(Enum.fromDescriptor(fileDescriptor.enumType[i])); | ||
filePackage.add(Enum.fromDescriptor(fileDescriptor.enumType[i], edition)); | ||
if (fileDescriptor.extension) | ||
for (i = 0; i < fileDescriptor.extension.length; ++i) | ||
filePackage.add(Field.fromDescriptor(fileDescriptor.extension[i])); | ||
filePackage.add(Field.fromDescriptor(fileDescriptor.extension[i], edition)); | ||
if (fileDescriptor.service) | ||
for (i = 0; i < fileDescriptor.service.length; ++i) | ||
filePackage.add(Service.fromDescriptor(fileDescriptor.service[i])); | ||
filePackage.add(Service.fromDescriptor(fileDescriptor.service[i], edition)); | ||
var opts = fromDescriptorOptions(fileDescriptor.options, exports.FileOptions); | ||
@@ -114,3 +134,3 @@ if (opts) { | ||
return root; | ||
return root.resolveAll(); | ||
}; | ||
@@ -121,7 +141,7 @@ | ||
* @returns {Message<IFileDescriptorSet>} Descriptor | ||
* @param {string} [syntax="proto2"] Syntax | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
*/ | ||
Root.prototype.toDescriptor = function toDescriptor(syntax) { | ||
Root.prototype.toDescriptor = function toDescriptor(edition) { | ||
var set = exports.FileDescriptorSet.create(); | ||
Root_toDescriptorRecursive(this, set.file, syntax); | ||
Root_toDescriptorRecursive(this, set.file, edition); | ||
return set; | ||
@@ -131,8 +151,7 @@ }; | ||
// Traverses a namespace and assembles the descriptor set | ||
function Root_toDescriptorRecursive(ns, files, syntax) { | ||
function Root_toDescriptorRecursive(ns, files, edition) { | ||
// Create a new file | ||
var file = exports.FileDescriptorProto.create({ name: ns.filename || (ns.fullName.substring(1).replace(/\./g, "_") || "root") + ".proto" }); | ||
if (syntax) | ||
file.syntax = syntax; | ||
editionToDescriptor(edition, file); | ||
if (!(ns instanceof Root)) | ||
@@ -144,11 +163,11 @@ file["package"] = ns.fullName.substring(1); | ||
if ((nested = ns._nestedArray[i]) instanceof Type) | ||
file.messageType.push(nested.toDescriptor(syntax)); | ||
file.messageType.push(nested.toDescriptor(edition)); | ||
else if (nested instanceof Enum) | ||
file.enumType.push(nested.toDescriptor()); | ||
else if (nested instanceof Field) | ||
file.extension.push(nested.toDescriptor(syntax)); | ||
file.extension.push(nested.toDescriptor(edition)); | ||
else if (nested instanceof Service) | ||
file.service.push(nested.toDescriptor()); | ||
else if (nested instanceof /* plain */ Namespace) | ||
Root_toDescriptorRecursive(nested, files, syntax); // requires new file | ||
Root_toDescriptorRecursive(nested, files, edition); // requires new file | ||
@@ -204,8 +223,11 @@ // Keep package-level options | ||
* Creates a type from a descriptor. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @param {IDescriptorProto|Reader|Uint8Array} descriptor Descriptor | ||
* @param {string} [syntax="proto2"] Syntax | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
* @param {boolean} [nested=false] Whether or not this is a nested object | ||
* @returns {Type} Type instance | ||
*/ | ||
Type.fromDescriptor = function fromDescriptor(descriptor, syntax) { | ||
Type.fromDescriptor = function fromDescriptor(descriptor, edition, nested) { | ||
// Decode the descriptor message if specified as a buffer: | ||
@@ -219,2 +241,5 @@ if (typeof descriptor.length === "number") | ||
if (!nested) | ||
type._edition = edition; | ||
/* Oneofs */ if (descriptor.oneofDecl) | ||
@@ -225,3 +250,3 @@ for (i = 0; i < descriptor.oneofDecl.length; ++i) | ||
for (i = 0; i < descriptor.field.length; ++i) { | ||
var field = Field.fromDescriptor(descriptor.field[i], syntax); | ||
var field = Field.fromDescriptor(descriptor.field[i], edition, true); | ||
type.add(field); | ||
@@ -233,6 +258,6 @@ if (descriptor.field[i].hasOwnProperty("oneofIndex")) // eslint-disable-line no-prototype-builtins | ||
for (i = 0; i < descriptor.extension.length; ++i) | ||
type.add(Field.fromDescriptor(descriptor.extension[i], syntax)); | ||
type.add(Field.fromDescriptor(descriptor.extension[i], edition, true)); | ||
/* Nested types */ if (descriptor.nestedType) | ||
for (i = 0; i < descriptor.nestedType.length; ++i) { | ||
type.add(Type.fromDescriptor(descriptor.nestedType[i], syntax)); | ||
type.add(Type.fromDescriptor(descriptor.nestedType[i], edition, true)); | ||
if (descriptor.nestedType[i].options && descriptor.nestedType[i].options.mapEntry) | ||
@@ -243,3 +268,3 @@ type.setOption("map_entry", true); | ||
for (i = 0; i < descriptor.enumType.length; ++i) | ||
type.add(Enum.fromDescriptor(descriptor.enumType[i])); | ||
type.add(Enum.fromDescriptor(descriptor.enumType[i], edition, true)); | ||
/* Extension ranges */ if (descriptor.extensionRange && descriptor.extensionRange.length) { | ||
@@ -266,5 +291,5 @@ type.extensions = []; | ||
* @returns {Message<IDescriptorProto>} Descriptor | ||
* @param {string} [syntax="proto2"] Syntax | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
*/ | ||
Type.prototype.toDescriptor = function toDescriptor(syntax) { | ||
Type.prototype.toDescriptor = function toDescriptor(edition) { | ||
var descriptor = exports.DescriptorProto.create({ name: this.name }), | ||
@@ -275,6 +300,6 @@ i; | ||
var fieldDescriptor; | ||
descriptor.field.push(fieldDescriptor = this._fieldsArray[i].toDescriptor(syntax)); | ||
descriptor.field.push(fieldDescriptor = this._fieldsArray[i].toDescriptor(edition)); | ||
if (this._fieldsArray[i] instanceof MapField) { // map fields are repeated FieldNameEntry | ||
var keyType = toDescriptorType(this._fieldsArray[i].keyType, this._fieldsArray[i].resolvedKeyType), | ||
valueType = toDescriptorType(this._fieldsArray[i].type, this._fieldsArray[i].resolvedType), | ||
var keyType = toDescriptorType(this._fieldsArray[i].keyType, this._fieldsArray[i].resolvedKeyType, false), | ||
valueType = toDescriptorType(this._fieldsArray[i].type, this._fieldsArray[i].resolvedType, false), | ||
valueTypeName = valueType === /* type */ 11 || valueType === /* enum */ 14 | ||
@@ -297,5 +322,5 @@ ? this._fieldsArray[i].resolvedType && shortname(this.parent, this._fieldsArray[i].resolvedType) || this._fieldsArray[i].type | ||
/* Extension fields */ if (this._nestedArray[i] instanceof Field) | ||
descriptor.field.push(this._nestedArray[i].toDescriptor(syntax)); | ||
descriptor.field.push(this._nestedArray[i].toDescriptor(edition)); | ||
/* Types */ else if (this._nestedArray[i] instanceof Type) | ||
descriptor.nestedType.push(this._nestedArray[i].toDescriptor(syntax)); | ||
descriptor.nestedType.push(this._nestedArray[i].toDescriptor(edition)); | ||
/* Enums */ else if (this._nestedArray[i] instanceof Enum) | ||
@@ -391,7 +416,11 @@ descriptor.enumType.push(this._nestedArray[i].toDescriptor()); | ||
* Creates a field from a descriptor. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @param {IFieldDescriptorProto|Reader|Uint8Array} descriptor Descriptor | ||
* @param {string} [syntax="proto2"] Syntax | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
* @param {boolean} [nested=false] Whether or not this is a top-level object | ||
* @returns {Field} Field instance | ||
*/ | ||
Field.fromDescriptor = function fromDescriptor(descriptor, syntax) { | ||
Field.fromDescriptor = function fromDescriptor(descriptor, edition, nested) { | ||
@@ -434,3 +463,8 @@ // Decode the descriptor message if specified as a buffer: | ||
if (!nested) | ||
field._edition = edition; | ||
field.options = fromDescriptorOptions(descriptor.options, exports.FieldOptions); | ||
if (descriptor.proto3_optional) | ||
field.options.proto3_optional = true; | ||
@@ -456,7 +490,7 @@ if (descriptor.defaultValue && descriptor.defaultValue.length) { | ||
if (packableDescriptorType(descriptor.type)) { | ||
if (syntax === "proto3") { // defaults to packed=true (internal preset is packed=true) | ||
if (edition === "proto3") { // defaults to packed=true (internal preset is packed=true) | ||
if (descriptor.options && !descriptor.options.packed) | ||
field.setOption("packed", false); | ||
} else if (!(descriptor.options && descriptor.options.packed)) // defaults to packed=false | ||
field.setOption("packed", false); | ||
} else if ((!edition || edition === "proto2") && descriptor.options && descriptor.options.packed) // defaults to packed=false | ||
field.setOption("packed", true); | ||
} | ||
@@ -470,5 +504,5 @@ | ||
* @returns {Message<IFieldDescriptorProto>} Descriptor | ||
* @param {string} [syntax="proto2"] Syntax | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
*/ | ||
Field.prototype.toDescriptor = function toDescriptor(syntax) { | ||
Field.prototype.toDescriptor = function toDescriptor(edition) { | ||
var descriptor = exports.FieldDescriptorProto.create({ name: this.name, number: this.id }); | ||
@@ -485,3 +519,3 @@ | ||
// Rewire field type | ||
switch (descriptor.type = toDescriptorType(this.type, this.resolve().resolvedType)) { | ||
switch (descriptor.type = toDescriptorType(this.type, this.resolve().resolvedType, this.delimited)) { | ||
case 10: // group | ||
@@ -495,8 +529,9 @@ case 11: // type | ||
// Rewire field rule | ||
switch (this.rule) { | ||
case "repeated": descriptor.label = 3; break; | ||
case "required": descriptor.label = 2; break; | ||
default: descriptor.label = 1; break; | ||
if (this.rule === "repeated") { | ||
descriptor.label = 3; | ||
} else if (this.required && edition === "proto2") { | ||
descriptor.label = 2; | ||
} else { | ||
descriptor.label = 1; | ||
} | ||
} | ||
@@ -516,8 +551,10 @@ | ||
descriptor.defaultValue = String(this.options["default"]); | ||
if (this.options.proto3_optional) | ||
descriptor.proto3_optional = true; | ||
} | ||
if (syntax === "proto3") { // defaults to packed=true | ||
if (edition === "proto3") { // defaults to packed=true | ||
if (!this.packed) | ||
(descriptor.options || (descriptor.options = exports.FieldOptions.create())).packed = false; | ||
} else if (this.packed) // defaults to packed=false | ||
} else if ((!edition || edition === "proto2") && this.packed) // defaults to packed=false | ||
(descriptor.options || (descriptor.options = exports.FieldOptions.create())).packed = true; | ||
@@ -557,6 +594,11 @@ | ||
* Creates an enum from a descriptor. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @param {IEnumDescriptorProto|Reader|Uint8Array} descriptor Descriptor | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
* @param {boolean} [nested=false] Whether or not this is a top-level object | ||
* @returns {Enum} Enum instance | ||
*/ | ||
Enum.fromDescriptor = function fromDescriptor(descriptor) { | ||
Enum.fromDescriptor = function fromDescriptor(descriptor, edition, nested) { | ||
@@ -576,3 +618,3 @@ // Decode the descriptor message if specified as a buffer: | ||
return new Enum( | ||
var enm = new Enum( | ||
descriptor.name && descriptor.name.length ? descriptor.name : "Enum" + unnamedEnumIndex++, | ||
@@ -582,2 +624,7 @@ values, | ||
); | ||
if (!nested) | ||
enm._edition = edition; | ||
return enm; | ||
}; | ||
@@ -616,2 +663,5 @@ | ||
* Creates a oneof from a descriptor. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @param {IOneofDescriptorProto|Reader|Uint8Array} descriptor Descriptor | ||
@@ -664,6 +714,11 @@ * @returns {OneOf} OneOf instance | ||
* Creates a service from a descriptor. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @param {IServiceDescriptorProto|Reader|Uint8Array} descriptor Descriptor | ||
* @param {string} [edition="proto2"] The syntax or edition to use | ||
* @param {boolean} [nested=false] Whether or not this is a top-level object | ||
* @returns {Service} Service instance | ||
*/ | ||
Service.fromDescriptor = function fromDescriptor(descriptor) { | ||
Service.fromDescriptor = function fromDescriptor(descriptor, edition, nested) { | ||
@@ -675,2 +730,4 @@ // Decode the descriptor message if specified as a buffer: | ||
var service = new Service(descriptor.name && descriptor.name.length ? descriptor.name : "Service" + unnamedServiceIndex++, fromDescriptorOptions(descriptor.options, exports.ServiceOptions)); | ||
if (!nested) | ||
service._edition = edition; | ||
if (descriptor.method) | ||
@@ -716,2 +773,5 @@ for (var i = 0; i < descriptor.method.length; ++i) | ||
* Properties of a MethodOptions message. | ||
* | ||
* Warning: this is not safe to use with editions protos, since it discards relevant file context. | ||
* | ||
* @interface IMethodOptions | ||
@@ -809,3 +869,3 @@ * @property {boolean} [deprecated] | ||
// Converts a protobuf.js basic type to a descriptor type | ||
function toDescriptorType(type, resolvedType) { | ||
function toDescriptorType(type, resolvedType, delimited) { | ||
switch (type) { | ||
@@ -832,6 +892,24 @@ // 0 is reserved for errors | ||
if (resolvedType instanceof Type) | ||
return resolvedType.group ? 10 : 11; | ||
return delimited ? 10 : 11; | ||
throw Error("illegal type: " + type); | ||
} | ||
function fixDescriptorOptionsRecursive(obj, type) { | ||
var val = {}; | ||
for (var i = 0, field, key; i < type.fieldsArray.length; ++i) { | ||
if ((key = (field = type._fieldsArray[i]).name) === "uninterpretedOption") continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue; | ||
var newKey = underScore(key); | ||
if (field.resolvedType instanceof Type) { | ||
val[newKey] = fixDescriptorOptionsRecursive(obj[key], field.resolvedType); | ||
} else if(field.resolvedType instanceof Enum) { | ||
val[newKey] = field.resolvedType.valuesById[obj[key]]; | ||
} else { | ||
val[newKey] = obj[key]; | ||
} | ||
} | ||
return val; | ||
} | ||
// Converts descriptor options to an options object | ||
@@ -841,14 +919,20 @@ function fromDescriptorOptions(options, type) { | ||
return undefined; | ||
var out = []; | ||
for (var i = 0, field, key, val; i < type.fieldsArray.length; ++i) | ||
if ((key = (field = type._fieldsArray[i]).name) !== "uninterpretedOption") | ||
if (options.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins | ||
val = options[key]; | ||
if (field.resolvedType instanceof Enum && typeof val === "number" && field.resolvedType.valuesById[val] !== undefined) | ||
val = field.resolvedType.valuesById[val]; | ||
out.push(underScore(key), val); | ||
} | ||
return out.length ? $protobuf.util.toObject(out) : undefined; | ||
return fixDescriptorOptionsRecursive(type.toObject(options), type); | ||
} | ||
function camelCaseRecursive(obj) { | ||
var val = {}; | ||
var keys = Object.keys(obj); | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
var newKey = $protobuf.util.camelCase(key); | ||
if (typeof obj[key] !== "object") { | ||
val[newKey] = obj[key]; | ||
} else { | ||
val[newKey] = camelCaseRecursive(obj[key]); | ||
} | ||
} | ||
return val; | ||
} | ||
// Converts an options object to descriptor options | ||
@@ -858,13 +942,3 @@ function toDescriptorOptions(options, type) { | ||
return undefined; | ||
var out = []; | ||
for (var i = 0, ks = Object.keys(options), key, val; i < ks.length; ++i) { | ||
val = options[key = ks[i]]; | ||
if (key === "default") | ||
continue; | ||
var field = type.fields[key]; | ||
if (!field && !(field = type.fields[key = $protobuf.util.camelCase(key)])) | ||
continue; | ||
out.push(key, val); | ||
} | ||
return out.length ? type.fromObject($protobuf.util.toObject(out)) : undefined; | ||
return type.fromObject(camelCaseRecursive(options)); | ||
} | ||
@@ -898,2 +972,33 @@ | ||
function editionFromDescriptor(fileDescriptor) { | ||
if (fileDescriptor.syntax === "editions") { | ||
switch(fileDescriptor.edition) { | ||
case exports.Edition.EDITION_2023: | ||
return "2023"; | ||
default: | ||
throw new Error("Unsupported edition " + fileDescriptor.edition); | ||
} | ||
} | ||
if (fileDescriptor.syntax === "proto3") { | ||
return "proto3"; | ||
} | ||
return "proto2"; | ||
} | ||
function editionToDescriptor(edition, fileDescriptor) { | ||
if (!edition) return; | ||
if (edition === "proto2" || edition === "proto3") { | ||
fileDescriptor.syntax = edition; | ||
} else { | ||
fileDescriptor.syntax = "editions"; | ||
switch(edition) { | ||
case "2023": | ||
fileDescriptor.edition = exports.Edition.EDITION_2023; | ||
break; | ||
default: | ||
throw new Error("Unsupported edition " + edition); | ||
} | ||
} | ||
} | ||
// --- exports --- | ||
@@ -900,0 +1005,0 @@ |
@@ -6,4 +6,14 @@ { | ||
"protobuf": { | ||
"options": { | ||
"go_package": "google.golang.org/protobuf/types/descriptorpb", | ||
"java_package": "com.google.protobuf", | ||
"java_outer_classname": "DescriptorProtos", | ||
"csharp_namespace": "Google.Protobuf.Reflection", | ||
"objc_class_prefix": "GPB", | ||
"cc_enable_arenas": true, | ||
"optimize_for": "SPEED" | ||
}, | ||
"nested": { | ||
"FileDescriptorSet": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -15,5 +25,29 @@ "file": { | ||
} | ||
}, | ||
"extensions": [ | ||
[ | ||
536000000, | ||
536000000 | ||
] | ||
] | ||
}, | ||
"Edition": { | ||
"edition": "proto2", | ||
"values": { | ||
"EDITION_UNKNOWN": 0, | ||
"EDITION_LEGACY": 900, | ||
"EDITION_PROTO2": 998, | ||
"EDITION_PROTO3": 999, | ||
"EDITION_2023": 1000, | ||
"EDITION_2024": 1001, | ||
"EDITION_1_TEST_ONLY": 1, | ||
"EDITION_2_TEST_ONLY": 2, | ||
"EDITION_99997_TEST_ONLY": 99997, | ||
"EDITION_99998_TEST_ONLY": 99998, | ||
"EDITION_99999_TEST_ONLY": 99999, | ||
"EDITION_MAX": 2147483647 | ||
} | ||
}, | ||
"FileDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -36,6 +70,3 @@ "name": { | ||
"type": "int32", | ||
"id": 10, | ||
"options": { | ||
"packed": false | ||
} | ||
"id": 10 | ||
}, | ||
@@ -45,6 +76,3 @@ "weakDependency": { | ||
"type": "int32", | ||
"id": 11, | ||
"options": { | ||
"packed": false | ||
} | ||
"id": 11 | ||
}, | ||
@@ -82,2 +110,6 @@ "messageType": { | ||
"id": 12 | ||
}, | ||
"edition": { | ||
"type": "Edition", | ||
"id": 14 | ||
} | ||
@@ -87,2 +119,3 @@ } | ||
"DescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -148,2 +181,6 @@ "name": { | ||
"id": 2 | ||
}, | ||
"options": { | ||
"type": "ExtensionRangeOptions", | ||
"id": 3 | ||
} | ||
@@ -166,3 +203,78 @@ } | ||
}, | ||
"ExtensionRangeOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
"uninterpretedOption": { | ||
"rule": "repeated", | ||
"type": "UninterpretedOption", | ||
"id": 999 | ||
}, | ||
"declaration": { | ||
"rule": "repeated", | ||
"type": "Declaration", | ||
"id": 2, | ||
"options": { | ||
"retention": "RETENTION_SOURCE" | ||
} | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 50 | ||
}, | ||
"verification": { | ||
"type": "VerificationState", | ||
"id": 3, | ||
"options": { | ||
"default": "UNVERIFIED", | ||
"retention": "RETENTION_SOURCE" | ||
} | ||
} | ||
}, | ||
"extensions": [ | ||
[ | ||
1000, | ||
536870911 | ||
] | ||
], | ||
"nested": { | ||
"Declaration": { | ||
"fields": { | ||
"number": { | ||
"type": "int32", | ||
"id": 1 | ||
}, | ||
"fullName": { | ||
"type": "string", | ||
"id": 2 | ||
}, | ||
"type": { | ||
"type": "string", | ||
"id": 3 | ||
}, | ||
"reserved": { | ||
"type": "bool", | ||
"id": 5 | ||
}, | ||
"repeated": { | ||
"type": "bool", | ||
"id": 6 | ||
} | ||
}, | ||
"reserved": [ | ||
[ | ||
4, | ||
4 | ||
] | ||
] | ||
}, | ||
"VerificationState": { | ||
"values": { | ||
"DECLARATION": 0, | ||
"UNVERIFIED": 1 | ||
} | ||
} | ||
} | ||
}, | ||
"FieldDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -208,2 +320,6 @@ "name": { | ||
"id": 8 | ||
}, | ||
"proto3Optional": { | ||
"type": "bool", | ||
"id": 17 | ||
} | ||
@@ -237,4 +353,4 @@ }, | ||
"LABEL_OPTIONAL": 1, | ||
"LABEL_REQUIRED": 2, | ||
"LABEL_REPEATED": 3 | ||
"LABEL_REPEATED": 3, | ||
"LABEL_REQUIRED": 2 | ||
} | ||
@@ -245,2 +361,3 @@ } | ||
"OneofDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -258,2 +375,3 @@ "name": { | ||
"EnumDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -272,6 +390,31 @@ "name": { | ||
"id": 3 | ||
}, | ||
"reservedRange": { | ||
"rule": "repeated", | ||
"type": "EnumReservedRange", | ||
"id": 4 | ||
}, | ||
"reservedName": { | ||
"rule": "repeated", | ||
"type": "string", | ||
"id": 5 | ||
} | ||
}, | ||
"nested": { | ||
"EnumReservedRange": { | ||
"fields": { | ||
"start": { | ||
"type": "int32", | ||
"id": 1 | ||
}, | ||
"end": { | ||
"type": "int32", | ||
"id": 2 | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"EnumValueDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -293,2 +436,3 @@ "name": { | ||
"ServiceDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -311,2 +455,3 @@ "name": { | ||
"MethodDescriptorProto": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -340,2 +485,3 @@ "name": { | ||
"FileOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -394,3 +540,6 @@ "javaPackage": { | ||
"type": "bool", | ||
"id": 31 | ||
"id": 31, | ||
"options": { | ||
"default": true | ||
} | ||
}, | ||
@@ -405,2 +554,26 @@ "objcClassPrefix": { | ||
}, | ||
"swiftPrefix": { | ||
"type": "string", | ||
"id": 39 | ||
}, | ||
"phpClassPrefix": { | ||
"type": "string", | ||
"id": 40 | ||
}, | ||
"phpNamespace": { | ||
"type": "string", | ||
"id": 41 | ||
}, | ||
"phpMetadataNamespace": { | ||
"type": "string", | ||
"id": 44 | ||
}, | ||
"rubyPackage": { | ||
"type": "string", | ||
"id": 45 | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 50 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -420,2 +593,7 @@ "rule": "repeated", | ||
[ | ||
42, | ||
42 | ||
], | ||
"php_generic_services", | ||
[ | ||
38, | ||
@@ -436,2 +614,3 @@ 38 | ||
"MessageOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -454,2 +633,13 @@ "messageSetWireFormat": { | ||
}, | ||
"deprecatedLegacyJsonFieldConflicts": { | ||
"type": "bool", | ||
"id": 11, | ||
"options": { | ||
"deprecated": true | ||
} | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 12 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -469,4 +659,20 @@ "rule": "repeated", | ||
[ | ||
4, | ||
4 | ||
], | ||
[ | ||
5, | ||
5 | ||
], | ||
[ | ||
6, | ||
6 | ||
], | ||
[ | ||
8, | ||
8 | ||
], | ||
[ | ||
9, | ||
9 | ||
] | ||
@@ -476,2 +682,3 @@ ] | ||
"FieldOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -500,2 +707,6 @@ "ctype": { | ||
}, | ||
"unverifiedLazy": { | ||
"type": "bool", | ||
"id": 15 | ||
}, | ||
"deprecated": { | ||
@@ -509,2 +720,28 @@ "type": "bool", | ||
}, | ||
"debugRedact": { | ||
"type": "bool", | ||
"id": 16 | ||
}, | ||
"retention": { | ||
"type": "OptionRetention", | ||
"id": 17 | ||
}, | ||
"targets": { | ||
"rule": "repeated", | ||
"type": "OptionTargetType", | ||
"id": 19 | ||
}, | ||
"editionDefaults": { | ||
"rule": "repeated", | ||
"type": "EditionDefault", | ||
"id": 20 | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 21 | ||
}, | ||
"featureSupport": { | ||
"type": "FeatureSupport", | ||
"id": 22 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -526,2 +763,6 @@ "rule": "repeated", | ||
4 | ||
], | ||
[ | ||
18, | ||
18 | ||
] | ||
@@ -543,2 +784,55 @@ ], | ||
} | ||
}, | ||
"OptionRetention": { | ||
"values": { | ||
"RETENTION_UNKNOWN": 0, | ||
"RETENTION_RUNTIME": 1, | ||
"RETENTION_SOURCE": 2 | ||
} | ||
}, | ||
"OptionTargetType": { | ||
"values": { | ||
"TARGET_TYPE_UNKNOWN": 0, | ||
"TARGET_TYPE_FILE": 1, | ||
"TARGET_TYPE_EXTENSION_RANGE": 2, | ||
"TARGET_TYPE_MESSAGE": 3, | ||
"TARGET_TYPE_FIELD": 4, | ||
"TARGET_TYPE_ONEOF": 5, | ||
"TARGET_TYPE_ENUM": 6, | ||
"TARGET_TYPE_ENUM_ENTRY": 7, | ||
"TARGET_TYPE_SERVICE": 8, | ||
"TARGET_TYPE_METHOD": 9 | ||
} | ||
}, | ||
"EditionDefault": { | ||
"fields": { | ||
"edition": { | ||
"type": "Edition", | ||
"id": 3 | ||
}, | ||
"value": { | ||
"type": "string", | ||
"id": 2 | ||
} | ||
} | ||
}, | ||
"FeatureSupport": { | ||
"fields": { | ||
"editionIntroduced": { | ||
"type": "Edition", | ||
"id": 1 | ||
}, | ||
"editionDeprecated": { | ||
"type": "Edition", | ||
"id": 2 | ||
}, | ||
"deprecationWarning": { | ||
"type": "string", | ||
"id": 3 | ||
}, | ||
"editionRemoved": { | ||
"type": "Edition", | ||
"id": 4 | ||
} | ||
} | ||
} | ||
@@ -548,3 +842,8 @@ } | ||
"OneofOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 1 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -564,2 +863,3 @@ "rule": "repeated", | ||
"EnumOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -574,2 +874,13 @@ "allowAlias": { | ||
}, | ||
"deprecatedLegacyJsonFieldConflicts": { | ||
"type": "bool", | ||
"id": 6, | ||
"options": { | ||
"deprecated": true | ||
} | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 7 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -586,5 +897,12 @@ "rule": "repeated", | ||
] | ||
], | ||
"reserved": [ | ||
[ | ||
5, | ||
5 | ||
] | ||
] | ||
}, | ||
"EnumValueOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -595,2 +913,14 @@ "deprecated": { | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 2 | ||
}, | ||
"debugRedact": { | ||
"type": "bool", | ||
"id": 3 | ||
}, | ||
"featureSupport": { | ||
"type": "FieldOptions.FeatureSupport", | ||
"id": 4 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -610,3 +940,8 @@ "rule": "repeated", | ||
"ServiceOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 34 | ||
}, | ||
"deprecated": { | ||
@@ -630,2 +965,3 @@ "type": "bool", | ||
"MethodOptions": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -636,2 +972,13 @@ "deprecated": { | ||
}, | ||
"idempotencyLevel": { | ||
"type": "IdempotencyLevel", | ||
"id": 34, | ||
"options": { | ||
"default": "IDEMPOTENCY_UNKNOWN" | ||
} | ||
}, | ||
"features": { | ||
"type": "FeatureSet", | ||
"id": 35 | ||
}, | ||
"uninterpretedOption": { | ||
@@ -648,5 +995,15 @@ "rule": "repeated", | ||
] | ||
] | ||
], | ||
"nested": { | ||
"IdempotencyLevel": { | ||
"values": { | ||
"IDEMPOTENCY_UNKNOWN": 0, | ||
"NO_SIDE_EFFECTS": 1, | ||
"IDEMPOTENT": 2 | ||
} | ||
} | ||
} | ||
}, | ||
"UninterpretedOption": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -700,3 +1057,156 @@ "name": { | ||
}, | ||
"FeatureSet": { | ||
"edition": "proto2", | ||
"fields": { | ||
"fieldPresence": { | ||
"type": "FieldPresence", | ||
"id": 1 | ||
}, | ||
"enumType": { | ||
"type": "EnumType", | ||
"id": 2 | ||
}, | ||
"repeatedFieldEncoding": { | ||
"type": "RepeatedFieldEncoding", | ||
"id": 3 | ||
}, | ||
"utf8Validation": { | ||
"type": "Utf8Validation", | ||
"id": 4 | ||
}, | ||
"messageEncoding": { | ||
"type": "MessageEncoding", | ||
"id": 5 | ||
}, | ||
"jsonFormat": { | ||
"type": "JsonFormat", | ||
"id": 6 | ||
}, | ||
"enforceNamingStyle": { | ||
"type": "EnforceNamingStyle", | ||
"id": 7 | ||
} | ||
}, | ||
"extensions": [ | ||
[ | ||
1000, | ||
9994 | ||
], | ||
[ | ||
9995, | ||
9999 | ||
], | ||
[ | ||
10000, | ||
10000 | ||
] | ||
], | ||
"reserved": [ | ||
[ | ||
999, | ||
999 | ||
] | ||
], | ||
"nested": { | ||
"FieldPresence": { | ||
"values": { | ||
"FIELD_PRESENCE_UNKNOWN": 0, | ||
"EXPLICIT": 1, | ||
"IMPLICIT": 2, | ||
"LEGACY_REQUIRED": 3 | ||
} | ||
}, | ||
"EnumType": { | ||
"values": { | ||
"ENUM_TYPE_UNKNOWN": 0, | ||
"OPEN": 1, | ||
"CLOSED": 2 | ||
} | ||
}, | ||
"RepeatedFieldEncoding": { | ||
"values": { | ||
"REPEATED_FIELD_ENCODING_UNKNOWN": 0, | ||
"PACKED": 1, | ||
"EXPANDED": 2 | ||
} | ||
}, | ||
"Utf8Validation": { | ||
"values": { | ||
"UTF8_VALIDATION_UNKNOWN": 0, | ||
"VERIFY": 2, | ||
"NONE": 3 | ||
} | ||
}, | ||
"MessageEncoding": { | ||
"values": { | ||
"MESSAGE_ENCODING_UNKNOWN": 0, | ||
"LENGTH_PREFIXED": 1, | ||
"DELIMITED": 2 | ||
} | ||
}, | ||
"JsonFormat": { | ||
"values": { | ||
"JSON_FORMAT_UNKNOWN": 0, | ||
"ALLOW": 1, | ||
"LEGACY_BEST_EFFORT": 2 | ||
} | ||
}, | ||
"EnforceNamingStyle": { | ||
"values": { | ||
"ENFORCE_NAMING_STYLE_UNKNOWN": 0, | ||
"STYLE2024": 1, | ||
"STYLE_LEGACY": 2 | ||
} | ||
} | ||
} | ||
}, | ||
"FeatureSetDefaults": { | ||
"edition": "proto2", | ||
"fields": { | ||
"defaults": { | ||
"rule": "repeated", | ||
"type": "FeatureSetEditionDefault", | ||
"id": 1 | ||
}, | ||
"minimumEdition": { | ||
"type": "Edition", | ||
"id": 4 | ||
}, | ||
"maximumEdition": { | ||
"type": "Edition", | ||
"id": 5 | ||
} | ||
}, | ||
"nested": { | ||
"FeatureSetEditionDefault": { | ||
"fields": { | ||
"edition": { | ||
"type": "Edition", | ||
"id": 3 | ||
}, | ||
"overridableFeatures": { | ||
"type": "FeatureSet", | ||
"id": 4 | ||
}, | ||
"fixedFeatures": { | ||
"type": "FeatureSet", | ||
"id": 5 | ||
} | ||
}, | ||
"reserved": [ | ||
[ | ||
1, | ||
1 | ||
], | ||
[ | ||
2, | ||
2 | ||
], | ||
"features" | ||
] | ||
} | ||
} | ||
}, | ||
"SourceCodeInfo": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -709,2 +1219,8 @@ "location": { | ||
}, | ||
"extensions": [ | ||
[ | ||
536000000, | ||
536000000 | ||
] | ||
], | ||
"nested": { | ||
@@ -716,3 +1232,6 @@ "Location": { | ||
"type": "int32", | ||
"id": 1 | ||
"id": 1, | ||
"options": { | ||
"packed": true | ||
} | ||
}, | ||
@@ -722,3 +1241,6 @@ "span": { | ||
"type": "int32", | ||
"id": 2 | ||
"id": 2, | ||
"options": { | ||
"packed": true | ||
} | ||
}, | ||
@@ -743,2 +1265,3 @@ "leadingComments": { | ||
"GeneratedCodeInfo": { | ||
"edition": "proto2", | ||
"fields": { | ||
@@ -757,3 +1280,6 @@ "annotation": { | ||
"type": "int32", | ||
"id": 1 | ||
"id": 1, | ||
"options": { | ||
"packed": true | ||
} | ||
}, | ||
@@ -771,3 +1297,16 @@ "sourceFile": { | ||
"id": 4 | ||
}, | ||
"semantic": { | ||
"type": "Semantic", | ||
"id": 5 | ||
} | ||
}, | ||
"nested": { | ||
"Semantic": { | ||
"values": { | ||
"NONE": 0, | ||
"SET": 1, | ||
"ALIAS": 2 | ||
} | ||
} | ||
} | ||
@@ -774,0 +1313,0 @@ } |
{ | ||
"name": "protobufjs", | ||
"version": "8.1.4-experimental", | ||
"version": "8.1.5-experimental", | ||
"versionScheme": "~", | ||
@@ -5,0 +5,0 @@ "description": "Protocol Buffers for JavaScript (& TypeScript).", |
@@ -355,2 +355,4 @@ "use strict"; | ||
this._resolveFeaturesRecursive(this._edition); | ||
var nested = this.nestedArray, i = 0; | ||
@@ -412,3 +414,3 @@ this.resolve(); | ||
// Early bailout for objects with matching absolute paths | ||
var found = this.root._fullyQualifiedObjects["." + flatPath]; | ||
var found = this.root._fullyQualifiedObjects && this.root._fullyQualifiedObjects["." + flatPath]; | ||
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) { | ||
@@ -415,0 +417,0 @@ return found; |
@@ -113,5 +113,2 @@ "use strict"; | ||
function finish(err, root) { | ||
if (root) { | ||
root.resolveAll(); | ||
} | ||
/* istanbul ignore if */ | ||
@@ -124,2 +121,5 @@ if (!callback) { | ||
} | ||
if (root) { | ||
root.resolveAll(); | ||
} | ||
var cb = callback; | ||
@@ -290,3 +290,2 @@ callback = null; | ||
}).join(", ")); | ||
this._resolveFeaturesRecursive(this._edition); | ||
return Namespace.prototype.resolveAll.call(this); | ||
@@ -293,0 +292,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2941692
0.89%31352
2.07%