protobufjs 7.2.2 → 7.2.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/dist/protobuf.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.1.0 (c) 2016, daniel wirtz
3
- * compiled fri, 09 sep 2022 03:02:57 utc
2
+ * protobuf.js v7.2.3 (c) 2016, daniel wirtz
3
+ * compiled mon, 27 mar 2023 18:08:22 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -1530,18 +1530,20 @@ var Enum = require(15),
1530
1530
  * @ignore
1531
1531
  */
1532
1532
  function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1533
+ var defaultAlreadyEmitted = false;
1533
1534
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
1534
1535
  if (field.resolvedType) {
1535
1536
  if (field.resolvedType instanceof Enum) { gen
1536
1537
  ("switch(d%s){", prop);
1537
1538
  for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
1538
1539
  // enum unknown values passthrough
1539
- if (values[keys[i]] === field.typeDefault) { gen
1540
+ if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
1540
1541
  ("default:")
1541
1542
  ("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
1542
1543
  if (!field.repeated) gen // fallback to default value only for
1543
1544
  // arrays, to avoid leaving holes.
1544
1545
  ("break"); // for non-repeated fields, just ignore
1546
+ defaultAlreadyEmitted = true;
1545
1547
  }
1546
1548
  gen
1547
1549
  ("case%j:", keys[i])
@@ -3356,9 +3358,8 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
3356
3358
  /**
3357
3359
  * Any nested object descriptor.
3358
3360
  * @typedef AnyNestedObject
3359
- * @type {IEnum|IType|IService|AnyExtensionField|INamespace}
3361
+ * @type {IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf}
3360
3362
  */
3361
- // ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)
3362
3363
 
3363
3364
  /**
3364
3365
  * Converts this namespace to a namespace descriptor.
@@ -4459,6 +4460,16 @@ function parse(source, root, options) {
4459
4460
  parseGroup(parent, rule);
4460
4461
  return;
4461
4462
  }
4463
+ // Type names can consume multiple tokens, in multiple variants:
4464
+ // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
4465
+ // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
4466
+ // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
4467
+ // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
4468
+ // Keep reading tokens until we get a type name with no period at the end,
4469
+ // and the next token does not start with a period.
4470
+ while (type.endsWith(".") || peek().startsWith(".")) {
4471
+ type += next();
4472
+ }
4462
4473
 
4463
4474
  /* istanbul ignore if */
4464
4475
  if (!typeRefRe.test(type))
@@ -5571,6 +5582,7 @@ Root.prototype.load = function load(filename, options, callback) {
5571
5582
 
5572
5583
  // Fetches a single file
5573
5584
  function fetch(filename, weak) {
5585
+ filename = getBundledFileName(filename) || filename;
5574
5586
 
5575
5587
  // Skip if already loaded / attempted
5576
5588
  if (self.files.indexOf(filename) > -1)
@@ -5699,6 +5711,10 @@ function tryHandleExtension(root, field) {
5699
5711
  var extendedType = field.parent.lookup(field.extend);
5700
5712
  if (extendedType) {
5701
5713
  var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);
5714
+ //do not allow to extend same field twice to prevent the error
5715
+ if (extendedType.get(sisterField.name)) {
5716
+ return true;
5717
+ }
5702
5718
  sisterField.declaringField = field;
5703
5719
  field.extensionField = sisterField;
5704
5720
  extendedType.add(sisterField);
@@ -8075,7 +8091,7 @@ function newError(name) {
8075
8091
  configurable: true,
8076
8092
  },
8077
8093
  name: {
8078
- get() { return name; },
8094
+ get: function get() { return name; },
8079
8095
  set: undefined,
8080
8096
  enumerable: false,
8081
8097
  // configurable: false would accurately preserve the behavior of
@@ -8085,7 +8101,7 @@ function newError(name) {
8085
8101
  configurable: true,
8086
8102
  },
8087
8103
  toString: {
8088
- value() { return this.name + ": " + this.message; },
8104
+ value: function value() { return this.name + ": " + this.message; },
8089
8105
  writable: true,
8090
8106
  enumerable: false,
8091
8107
  configurable: true,