protobufjs 5.0.0 → 5.0.1

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.
Files changed (49) hide show
  1. package/bower.json +1 -1
  2. package/cli/pbjs/targets/json.js +1 -1
  3. package/cli/pbjs/targets/proto.js +10 -2
  4. package/dist/protobuf-light.js +38 -21
  5. package/dist/protobuf-light.min.js +78 -78
  6. package/dist/protobuf-light.min.js.gz +0 -0
  7. package/dist/protobuf-light.min.map +2 -2
  8. package/dist/protobuf.js +81 -55
  9. package/dist/protobuf.min.js +92 -92
  10. package/dist/protobuf.min.js.gz +0 -0
  11. package/dist/protobuf.min.map +2 -2
  12. package/docs/ProtoBuf.Builder.Message.html +106 -37
  13. package/docs/ProtoBuf.Builder.Service.html +9 -9
  14. package/docs/ProtoBuf.Builder.html +22 -22
  15. package/docs/ProtoBuf.DotProto.Parser.html +3 -3
  16. package/docs/ProtoBuf.DotProto.Tokenizer.html +1 -1
  17. package/docs/ProtoBuf.DotProto.html +1 -1
  18. package/docs/ProtoBuf.Map.html +6 -6
  19. package/docs/ProtoBuf.Reflect.Element.html +7 -7
  20. package/docs/ProtoBuf.Reflect.Enum.Value.html +10 -10
  21. package/docs/ProtoBuf.Reflect.Enum.html +21 -21
  22. package/docs/ProtoBuf.Reflect.Extension.html +3 -3
  23. package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +29 -29
  24. package/docs/ProtoBuf.Reflect.Message.Field.html +28 -28
  25. package/docs/ProtoBuf.Reflect.Message.OneOf.html +10 -10
  26. package/docs/ProtoBuf.Reflect.Message.html +31 -28
  27. package/docs/ProtoBuf.Reflect.Namespace.html +19 -19
  28. package/docs/ProtoBuf.Reflect.Service.Method.html +11 -11
  29. package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +17 -17
  30. package/docs/ProtoBuf.Reflect.Service.html +20 -20
  31. package/docs/ProtoBuf.Reflect.T.html +9 -9
  32. package/docs/ProtoBuf.Reflect.html +2 -2
  33. package/docs/ProtoBuf.Util.html +1 -1
  34. package/docs/ProtoBuf.html +8 -8
  35. package/docs/ProtoBuf.js.html +82 -56
  36. package/docs/index.html +1 -1
  37. package/externs/protobuf.js +2 -1
  38. package/package.json +1 -1
  39. package/src/ProtoBuf/Builder/Message.js +8 -3
  40. package/src/ProtoBuf/Builder/Service.js +3 -0
  41. package/src/ProtoBuf/Builder.js +15 -8
  42. package/src/ProtoBuf/DotProto/Parser.js +43 -34
  43. package/src/ProtoBuf/Reflect/Element.js +4 -3
  44. package/src/ProtoBuf/Reflect/Message/Field.js +4 -3
  45. package/src/ProtoBuf/Reflect/Message.js +3 -3
  46. package/src/google/protobuf/descriptor.json +28 -14
  47. package/tests/imports-weak.proto +7 -0
  48. package/tests/suite.js +63 -83
  49. package/tests/gtfs-realtime.proto +0 -552
@@ -484,8 +484,10 @@
484
484
  }
485
485
  ],
486
486
  "extensions": [
487
- 1000,
488
- 536870911
487
+ [
488
+ 1000,
489
+ 536870911
490
+ ]
489
491
  ],
490
492
  "enums": [
491
493
  {
@@ -536,8 +538,10 @@
536
538
  }
537
539
  ],
538
540
  "extensions": [
539
- 1000,
540
- 536870911
541
+ [
542
+ 1000,
543
+ 536870911
544
+ ]
541
545
  ]
542
546
  },
543
547
  {
@@ -599,8 +603,10 @@
599
603
  }
600
604
  ],
601
605
  "extensions": [
602
- 1000,
603
- 536870911
606
+ [
607
+ 1000,
608
+ 536870911
609
+ ]
604
610
  ],
605
611
  "enums": [
606
612
  {
@@ -642,8 +648,10 @@
642
648
  }
643
649
  ],
644
650
  "extensions": [
645
- 1000,
646
- 536870911
651
+ [
652
+ 1000,
653
+ 536870911
654
+ ]
647
655
  ]
648
656
  },
649
657
  {
@@ -657,8 +665,10 @@
657
665
  }
658
666
  ],
659
667
  "extensions": [
660
- 1000,
661
- 536870911
668
+ [
669
+ 1000,
670
+ 536870911
671
+ ]
662
672
  ]
663
673
  },
664
674
  {
@@ -672,8 +682,10 @@
672
682
  }
673
683
  ],
674
684
  "extensions": [
675
- 1000,
676
- 536870911
685
+ [
686
+ 1000,
687
+ 536870911
688
+ ]
677
689
  ]
678
690
  },
679
691
  {
@@ -687,8 +699,10 @@
687
699
  }
688
700
  ],
689
701
  "extensions": [
690
- 1000,
691
- 536870911
702
+ [
703
+ 1000,
704
+ 536870911
705
+ ]
692
706
  ]
693
707
  },
694
708
  {
@@ -0,0 +1,7 @@
1
+ package My;
2
+
3
+ import weak "example1.proto";
4
+
5
+ message Test2 {
6
+ required Test1 test1 = 1;
7
+ }
package/tests/suite.js CHANGED
@@ -914,6 +914,19 @@
914
914
  test.done();
915
915
  },
916
916
 
917
+ "weakImports": function(test) {
918
+ try {
919
+ var builder = ProtoBuf.loadProtoFile(__dirname+"/imports-weak.proto");
920
+ var root = builder.build();
921
+ } catch (e) {
922
+ test.ok(e.message.indexOf("unresolvable type reference") >= 0);
923
+ test.done();
924
+ return;
925
+ }
926
+ var e = new Error("Weak import was imported.");
927
+ fail(e);
928
+ },
929
+
917
930
  "importExtensions": function(test) {
918
931
  var x = "package x; \
919
932
  message Test { \
@@ -1046,85 +1059,51 @@
1046
1059
  "extend": function(test) {
1047
1060
  try {
1048
1061
  var ast = new ProtoBuf.DotProto.Parser(fs.readFileSync(__dirname+"/extend.proto")).parse();
1049
- test.deepEqual(ast, {
1050
- "package": null,
1051
- "messages": [
1052
- {
1053
- "ref": "google.protobuf.MessageOptions",
1054
- "fields": [
1055
- {
1056
- "rule": "optional",
1057
- "options": {},
1058
- "type": "int32",
1059
- "name": "foo",
1060
- "id": 1001
1061
- }
1062
- ]
1063
- },
1064
- {
1065
- "name": "Foo",
1066
- "fields": [],
1067
- "enums": [],
1068
- "messages": [],
1069
- "options": {},
1070
- "services": [],
1071
- "extensions": [
1072
- 2,
1073
- 536870911
1074
- ],
1075
- "oneofs": []
1076
- },
1077
- {
1078
- "ref": "Foo",
1079
- "fields":[
1080
- {
1081
- "rule": "optional",
1082
- "options": {},
1083
- "type": "string",
1084
- "name": "bar",
1085
- "id": 2
1086
- }
1087
- ]
1088
- },
1089
- {
1090
- "name": "Bar",
1091
- "fields": [],
1092
- "enums": [],
1093
- "messages": [
1094
- {
1095
- "name": "Foo",
1096
- "fields": [],
1097
- "enums": [],
1098
- "messages": [],
1099
- "services": [],
1100
- "options": {},
1101
- "oneofs": []
1102
- },
1103
- {
1104
- "ref": ".Foo",
1105
- "fields": [
1106
- {
1107
- "rule": "optional",
1108
- "options": {},
1109
- "type": "Foo",
1110
- "name": "foo",
1111
- "id": 3
1112
- }
1113
- ]
1114
- }
1115
- ],
1116
- "options": {},
1117
- "services": [],
1118
- "oneofs": []
1119
- }
1120
- ],
1121
- "enums": [],
1122
- "imports": [
1123
- "google/protobuf/descriptor.proto"
1124
- ],
1125
- "options": {},
1126
- "services": []
1127
- });
1062
+ test.deepEqual(ast, { package: null,
1063
+ messages:
1064
+ [ { ref: 'google.protobuf.MessageOptions',
1065
+ fields:
1066
+ [ { rule: 'optional',
1067
+ type: 'int32',
1068
+ name: 'foo',
1069
+ options: {},
1070
+ id: 1001 } ] },
1071
+ { name: 'Foo',
1072
+ fields: [],
1073
+ enums: [],
1074
+ messages: [],
1075
+ options: {},
1076
+ services: [],
1077
+ oneofs: {},
1078
+ extensions: [ [ 2, 536870911 ] ] },
1079
+ { ref: 'Foo',
1080
+ fields:
1081
+ [ { rule: 'optional',
1082
+ type: 'string',
1083
+ name: 'bar',
1084
+ options: {},
1085
+ id: 2 } ] },
1086
+ { name: 'Bar',
1087
+ fields: [],
1088
+ enums: [],
1089
+ messages:
1090
+ [ { name: 'Foo',
1091
+ fields: [],
1092
+ enums: [],
1093
+ messages: [],
1094
+ options: {},
1095
+ services: [],
1096
+ oneofs: {} },
1097
+ { ref: '.Foo',
1098
+ fields: [ { rule: 'optional', type: 'Foo', name: 'foo', options: {}, id: 3 } ] } ],
1099
+ options: {},
1100
+ services: [],
1101
+ oneofs: {} } ],
1102
+ enums: [],
1103
+ imports: [ 'google/protobuf/descriptor.proto' ],
1104
+ options: {},
1105
+ services: [] }
1106
+ );
1128
1107
 
1129
1108
  var builder = ProtoBuf.loadProtoFile(__dirname+"/extend.proto");
1130
1109
  var TFoo = builder.lookup(".Foo"),
@@ -1136,8 +1115,8 @@
1136
1115
  test.strictEqual(fields[0].id, 2);
1137
1116
  test.strictEqual(fields[1].name, ".Bar.foo");
1138
1117
  test.strictEqual(fields[1].id, 3);
1139
- test.deepEqual(TFoo.extensions, [2, ProtoBuf.ID_MAX]); // Defined
1140
- test.deepEqual(TBar.extensions, [ProtoBuf.ID_MIN, ProtoBuf.ID_MAX]); // Undefined
1118
+ test.deepEqual(TFoo.extensions, [[2, ProtoBuf.ID_MAX]]); // explicitly defined
1119
+ test.strictEqual(TBar.extensions, undefined); // none defined
1141
1120
  test.deepEqual(TBar.getChild("foo"), { builder: builder, parent: TBar, name: "foo", field: TFoo.getChild('.Bar.foo') });
1142
1121
  test.strictEqual(TBar.getChildren(ProtoBuf.Reflect.Message.Field).length, 0);
1143
1122
  var root = builder.build();
@@ -1275,7 +1254,8 @@
1275
1254
  },
1276
1255
 
1277
1256
  // Properly ignore "syntax" and "extensions" keywords
1278
- "gtfs-realtime": function(test) {
1257
+ // The corresponding .proto file has been removed upon request
1258
+ /* "gtfs-realtime": function(test) {
1279
1259
  try {
1280
1260
  test.doesNotThrow(function() {
1281
1261
  ProtoBuf.loadProtoFile(__dirname+"/gtfs-realtime.proto");
@@ -1284,7 +1264,7 @@
1284
1264
  fail(e);
1285
1265
  }
1286
1266
  test.done();
1287
- },
1267
+ }, */
1288
1268
 
1289
1269
  "delimited": function(test) {
1290
1270
  try {