protobufjs 7.5.4 → 8.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protobufjs",
3
- "version": "7.5.4",
3
+ "version": "8.0.0",
4
4
  "versionScheme": "~",
5
5
  "description": "Protocol Buffers for JavaScript (& TypeScript).",
6
6
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
package/src/object.js CHANGED
@@ -10,9 +10,10 @@ var Root; // cyclic
10
10
 
11
11
  /* eslint-disable no-warning-comments */
12
12
  // TODO: Replace with embedded proto.
13
- var editions2023Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY"};
14
- var proto2Defaults = {enum_type: "CLOSED", field_presence: "EXPLICIT", json_format: "LEGACY_BEST_EFFORT", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "EXPANDED", utf8_validation: "NONE"};
15
- var proto3Defaults = {enum_type: "OPEN", field_presence: "IMPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY"};
13
+ var editions2024Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE2024", default_symbol_visibility: "EXPORT_TOP_LEVEL" };
14
+ var editions2023Defaults = {enum_type: "OPEN", field_presence: "EXPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
15
+ var proto2Defaults = {enum_type: "CLOSED", field_presence: "EXPLICIT", json_format: "LEGACY_BEST_EFFORT", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "EXPANDED", utf8_validation: "NONE", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
16
+ var proto3Defaults = {enum_type: "OPEN", field_presence: "IMPLICIT", json_format: "ALLOW", message_encoding: "LENGTH_PREFIXED", repeated_field_encoding: "PACKED", utf8_validation: "VERIFY", enforce_naming_style: "STYLE_LEGACY", default_symbol_visibility: "EXPORT_ALL" };
16
17
 
17
18
  /**
18
19
  * Constructs a new reflection object instance.
@@ -225,6 +226,8 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
225
226
  defaults = Object.assign({}, proto3Defaults);
226
227
  } else if (edition === "2023") {
227
228
  defaults = Object.assign({}, editions2023Defaults);
229
+ } else if (edition === "2024") {
230
+ defaults = Object.assign({}, editions2024Defaults);
228
231
  } else {
229
232
  throw new Error("Unknown edition: " + edition);
230
233
  }
package/src/parse.js CHANGED
@@ -261,6 +261,16 @@ function parse(source, root, options) {
261
261
  var token = peek();
262
262
  var whichImports;
263
263
  switch (token) {
264
+ case "option":
265
+ if (edition < "2024") {
266
+ throw illegal("option");
267
+ }
268
+ // Import options are only used for resolving options, which we don't
269
+ // do. We can just throw them out.
270
+ next();
271
+ readString();
272
+ skip(";");
273
+ return;
264
274
  case "weak":
265
275
  whichImports = weakImports || (weakImports = []);
266
276
  next();
@@ -291,7 +301,7 @@ function parse(source, root, options) {
291
301
  function parseEdition() {
292
302
  skip("=");
293
303
  edition = readString();
294
- const supportedEditions = ["2023"];
304
+ const supportedEditions = ["2023", "2024"];
295
305
 
296
306
  /* istanbul ignore if */
297
307
  if (!supportedEditions.includes(edition))
@@ -317,6 +327,22 @@ function parse(source, root, options) {
317
327
  parseEnum(parent, token);
318
328
  return true;
319
329
 
330
+ case "export":
331
+ case "local":
332
+ if (edition < "2024") {
333
+ return false;
334
+ }
335
+ token = next();
336
+ if (token === "export" || token === "local") {
337
+ return false;
338
+ }
339
+ if (token !== "message" && token !== "enum") {
340
+ return false;
341
+ }
342
+ /* eslint-disable no-warning-comments */
343
+ // TODO: actually enforce visiblity modifiers like protoc does.
344
+ return parseCommon(parent, token);
345
+
320
346
  case "service":
321
347
  parseService(parent, token);
322
348
  return true;
@@ -527,6 +553,24 @@ function parse(source, root, options) {
527
553
  readRanges(type.reserved || (type.reserved = []), true);
528
554
  break;
529
555
 
556
+ case "export":
557
+ case "local":
558
+ if (edition < "2024") {
559
+ throw illegal(token);
560
+ }
561
+ token = next();
562
+ switch (token) {
563
+ case "message":
564
+ parseType(type, token);
565
+ break;
566
+ case "enum":
567
+ parseType(type, token);
568
+ break;
569
+ default:
570
+ throw illegal(token);
571
+ }
572
+ break;
573
+
530
574
  /* istanbul ignore next */
531
575
  default:
532
576
  throw illegal(token); // there are no groups with proto3 semantics