protobufjs 4.1.2 → 5.0.2

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 (188) hide show
  1. package/.travis.yml +3 -1
  2. package/README.md +147 -25
  3. package/bin/pbjs +2 -2
  4. package/bower.json +3 -3
  5. package/cli/pbjs/targets/amd.js +1 -1
  6. package/cli/pbjs/targets/json.js +9 -1
  7. package/cli/pbjs/targets/proto.js +48 -24
  8. package/cli/pbjs/util.js +1 -1
  9. package/cli/pbjs.js +9 -2
  10. package/dist/README.md +10 -10
  11. package/dist/{ProtoBuf-light.js → protobuf-light.js} +207 -152
  12. package/dist/protobuf-light.min.js +94 -0
  13. package/dist/protobuf-light.min.js.gz +0 -0
  14. package/dist/protobuf-light.min.map +8 -0
  15. package/dist/{ProtoBuf.js → protobuf.js} +265 -175
  16. package/dist/protobuf.min.js +116 -0
  17. package/dist/protobuf.min.js.gz +0 -0
  18. package/dist/protobuf.min.map +8 -0
  19. package/docs/ProtoBuf.Builder.Message.html +1473 -967
  20. package/docs/ProtoBuf.Builder.Service.html +266 -197
  21. package/docs/ProtoBuf.Builder.html +758 -542
  22. package/docs/ProtoBuf.DotProto.Parser.html +223 -161
  23. package/docs/ProtoBuf.DotProto.Tokenizer.html +344 -248
  24. package/docs/ProtoBuf.DotProto.html +20 -12
  25. package/docs/ProtoBuf.Element.html +554 -554
  26. package/docs/ProtoBuf.Map.html +158 -123
  27. package/docs/ProtoBuf.Reflect.Element.html +286 -143
  28. package/docs/ProtoBuf.Reflect.Enum.Value.html +329 -228
  29. package/docs/ProtoBuf.Reflect.Enum.html +757 -537
  30. package/docs/ProtoBuf.Reflect.Extension.html +73 -56
  31. package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +1013 -740
  32. package/docs/ProtoBuf.Reflect.Message.Field.html +926 -649
  33. package/docs/ProtoBuf.Reflect.Message.OneOf.html +327 -245
  34. package/docs/ProtoBuf.Reflect.Message.html +919 -652
  35. package/docs/ProtoBuf.Reflect.Namespace.html +648 -447
  36. package/docs/ProtoBuf.Reflect.Service.Method.html +363 -251
  37. package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +545 -397
  38. package/docs/ProtoBuf.Reflect.Service.html +721 -511
  39. package/docs/ProtoBuf.Reflect.T.html +268 -197
  40. package/docs/ProtoBuf.Reflect.html +20 -12
  41. package/docs/ProtoBuf.Util.html +169 -118
  42. package/docs/ProtoBuf.html +840 -628
  43. package/docs/ProtoBuf.js.html +271 -180
  44. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  45. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  46. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  47. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  48. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  49. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  50. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  51. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  52. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  53. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  54. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  55. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  56. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  57. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  58. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  59. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  60. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  61. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  62. package/docs/index.html +7 -5
  63. package/docs/styles/jsdoc-default.css +95 -75
  64. package/docs/styles/prettify-tomorrow.css +1 -1
  65. package/donate.png +0 -0
  66. package/examples/protoify/json.js +123 -123
  67. package/examples/protoify/json.json +123 -123
  68. package/examples/websocket/server.js +4 -4
  69. package/externs/{ProtoBuf.js → protobuf.js} +933 -922
  70. package/index.js +1 -18
  71. package/jsdoc.json +1 -1
  72. package/package.json +11 -11
  73. package/protobuf.png +0 -0
  74. package/scripts/build.js +53 -58
  75. package/src/ProtoBuf/Builder/Message.js +18 -9
  76. package/src/ProtoBuf/Builder/Service.js +3 -0
  77. package/src/ProtoBuf/Builder.js +34 -10
  78. package/src/ProtoBuf/DotProto/Parser.js +58 -23
  79. package/src/ProtoBuf/Reflect/Element.js +17 -4
  80. package/src/ProtoBuf/Reflect/Message/Field.js +6 -5
  81. package/src/ProtoBuf/Reflect/Message.js +9 -4
  82. package/src/ProtoBuf/Util.js +116 -116
  83. package/src/bower.json +2 -2
  84. package/src/google/protobuf/descriptor.json +55 -15
  85. package/src/{ProtoBuf.js → protobuf.js} +0 -0
  86. package/src/wrap.js +4 -4
  87. package/tests/bench.txt +373 -373
  88. package/tests/complex.json +8 -1
  89. package/tests/custom-options.json +169 -169
  90. package/tests/extend.json +71 -71
  91. package/tests/imports-weak.proto +7 -0
  92. package/tests/imports.json +83 -83
  93. package/tests/nodeunit-browser/nodeunit.css +70 -70
  94. package/tests/nodeunit-browser/nodeunit.js +2108 -2108
  95. package/tests/options.json +32 -32
  96. package/tests/proto2js/Bar.json +46 -46
  97. package/tests/suite.js +107 -82
  98. package/ProtoBuf.png +0 -0
  99. package/dist/ProtoBuf-light.min.js +0 -87
  100. package/dist/ProtoBuf-light.min.js.gz +0 -0
  101. package/dist/ProtoBuf-light.min.map +0 -8
  102. package/dist/ProtoBuf.min.js +0 -108
  103. package/dist/ProtoBuf.min.js.gz +0 -0
  104. package/dist/ProtoBuf.min.map +0 -8
  105. package/externs/ByteBuffer.js +0 -767
  106. package/externs/Long.js +0 -328
  107. package/sandbox/gapi/googleapis/google/api/annotations.proto +0 -29
  108. package/sandbox/gapi/googleapis/google/api/http.proto +0 -245
  109. package/sandbox/gapi/googleapis/google/datastore/v1beta3/datastore.proto +0 -281
  110. package/sandbox/gapi/googleapis/google/datastore/v1beta3/entity.proto +0 -189
  111. package/sandbox/gapi/googleapis/google/datastore/v1beta3/query.proto +0 -281
  112. package/sandbox/gapi/googleapis/google/longrunning/operations.proto +0 -144
  113. package/sandbox/gapi/googleapis/google/protobuf/any.proto +0 -98
  114. package/sandbox/gapi/googleapis/google/protobuf/any_test.proto +0 -41
  115. package/sandbox/gapi/googleapis/google/protobuf/api.proto +0 -201
  116. package/sandbox/gapi/googleapis/google/protobuf/descriptor.proto +0 -773
  117. package/sandbox/gapi/googleapis/google/protobuf/duration.proto +0 -95
  118. package/sandbox/gapi/googleapis/google/protobuf/empty.proto +0 -50
  119. package/sandbox/gapi/googleapis/google/protobuf/field_mask.proto +0 -167
  120. package/sandbox/gapi/googleapis/google/protobuf/map_lite_unittest.proto +0 -130
  121. package/sandbox/gapi/googleapis/google/protobuf/map_proto2_unittest.proto +0 -60
  122. package/sandbox/gapi/googleapis/google/protobuf/map_unittest.proto +0 -129
  123. package/sandbox/gapi/googleapis/google/protobuf/map_unittest_proto3.proto +0 -120
  124. package/sandbox/gapi/googleapis/google/protobuf/source_context.proto +0 -47
  125. package/sandbox/gapi/googleapis/google/protobuf/struct.proto +0 -94
  126. package/sandbox/gapi/googleapis/google/protobuf/timestamp.proto +0 -107
  127. package/sandbox/gapi/googleapis/google/protobuf/type.proto +0 -176
  128. package/sandbox/gapi/googleapis/google/protobuf/unittest.proto +0 -878
  129. package/sandbox/gapi/googleapis/google/protobuf/unittest_arena.proto +0 -46
  130. package/sandbox/gapi/googleapis/google/protobuf/unittest_custom_options.proto +0 -394
  131. package/sandbox/gapi/googleapis/google/protobuf/unittest_drop_unknown_fields.proto +0 -58
  132. package/sandbox/gapi/googleapis/google/protobuf/unittest_embed_optimize_for.proto +0 -51
  133. package/sandbox/gapi/googleapis/google/protobuf/unittest_empty.proto +0 -38
  134. package/sandbox/gapi/googleapis/google/protobuf/unittest_enormous_descriptor.proto +0 -1048
  135. package/sandbox/gapi/googleapis/google/protobuf/unittest_import.proto +0 -66
  136. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_lite.proto +0 -52
  137. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_proto3.proto +0 -68
  138. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public.proto +0 -41
  139. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_lite.proto +0 -43
  140. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_proto3.proto +0 -42
  141. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite.proto +0 -385
  142. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite_imports_nonlite.proto +0 -44
  143. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset.proto +0 -82
  144. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset_wire_format.proto +0 -52
  145. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena.proto +0 -202
  146. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_import.proto +0 -37
  147. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_lite.proto +0 -42
  148. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_field_presence.proto +0 -138
  149. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_generic_services.proto +0 -54
  150. package/sandbox/gapi/googleapis/google/protobuf/unittest_optimize_for.proto +0 -67
  151. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum.proto +0 -71
  152. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum2.proto +0 -50
  153. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3.proto +0 -388
  154. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3_arena.proto +0 -206
  155. package/sandbox/gapi/googleapis/google/protobuf/unittest_well_known_types.proto +0 -112
  156. package/sandbox/gapi/googleapis/google/protobuf/unknown_enum_test.proto +0 -62
  157. package/sandbox/gapi/googleapis/google/protobuf/wrappers.proto +0 -117
  158. package/sandbox/gapi/googleapis/google/rpc/code.proto +0 -190
  159. package/sandbox/gapi/googleapis/google/rpc/error_details.proto +0 -157
  160. package/sandbox/gapi/googleapis/google/rpc/status.proto +0 -90
  161. package/sandbox/gapi/googleapis/google/type/color.proto +0 -163
  162. package/sandbox/gapi/googleapis/google/type/date.proto +0 -43
  163. package/sandbox/gapi/googleapis/google/type/dayofweek.proto +0 -50
  164. package/sandbox/gapi/googleapis/google/type/latlng.proto +0 -36
  165. package/sandbox/gapi/googleapis/google/type/money.proto +0 -40
  166. package/sandbox/gapi/googleapis/google/type/timeofday.proto +0 -42
  167. package/sandbox/gapi/test.js +0 -17
  168. package/sandbox/gapi/test.proto +0 -12
  169. package/sandbox/issue146/MyOptions.proto +0 -28
  170. package/sandbox/issue146/Sample.proto +0 -21
  171. package/sandbox/issue146/main.js +0 -3
  172. package/sandbox/issue147/enum.proto +0 -8
  173. package/sandbox/issue147/main.js +0 -3
  174. package/sandbox/issue182/commands.proto +0 -10
  175. package/sandbox/issue182/execute.js +0 -22
  176. package/sandbox/issue182/session_commands.proto +0 -14
  177. package/sandbox/issue289/A.proto +0 -8
  178. package/sandbox/issue289/B.proto +0 -8
  179. package/sandbox/issue289/common.proto +0 -5
  180. package/sandbox/issue289/main.js +0 -7
  181. package/sandbox/issue300/IAuth.proto +0 -14
  182. package/sandbox/issue300/Request.proto +0 -14
  183. package/sandbox/issue300/main.js +0 -26
  184. package/sandbox/issue42/innerextend.proto +0 -18
  185. package/sandbox/issue42/main.js +0 -8
  186. package/sandbox/issue42/outerextend.proto +0 -17
  187. package/tests/gtfs-realtime.proto +0 -552
  188. package/webpack.config.js +0 -9
@@ -1,32 +1,32 @@
1
- {
2
- "package": "My",
3
- "messages": [
4
- {
5
- "name": "Test",
6
- "fields": [
7
- {
8
- "rule": "optional",
9
- "options": {
10
- "default": "Max"
11
- },
12
- "type": "string",
13
- "name": "name",
14
- "id": 1
15
- }
16
- ],
17
- "enums": [],
18
- "messages": [],
19
- "options": {
20
- "(inmessage)": "My.Test",
21
- "(foo.my_option).bar": false
22
- }
23
- }
24
- ],
25
- "enums": [],
26
- "imports": [],
27
- "options": {
28
- "(toplevel_1)": 10,
29
- "(toplevel_2)": "Hello world!"
30
- },
31
- "services": []
32
- }
1
+ {
2
+ "package": "My",
3
+ "messages": [
4
+ {
5
+ "name": "Test",
6
+ "fields": [
7
+ {
8
+ "rule": "optional",
9
+ "options": {
10
+ "default": "Max"
11
+ },
12
+ "type": "string",
13
+ "name": "name",
14
+ "id": 1
15
+ }
16
+ ],
17
+ "enums": [],
18
+ "messages": [],
19
+ "options": {
20
+ "(inmessage)": "My.Test",
21
+ "(foo.my_option).bar": false
22
+ }
23
+ }
24
+ ],
25
+ "enums": [],
26
+ "imports": [],
27
+ "options": {
28
+ "(toplevel_1)": 10,
29
+ "(toplevel_2)": "Hello world!"
30
+ },
31
+ "services": []
32
+ }
@@ -1,46 +1,46 @@
1
- {
2
- "package": null,
3
- "messages": [
4
- {
5
- "ref": "Foo",
6
- "fields": [
7
- {
8
- "rule": "required",
9
- "type": "string",
10
- "name": "buzz",
11
- "id": 2,
12
- "options": {}
13
- }
14
- ]
15
- }
16
- ],
17
- "enums": [],
18
- "imports": [
19
- {
20
- "package": null,
21
- "messages": [
22
- {
23
- "name": "Foo",
24
- "fields": [
25
- {
26
- "rule": "required",
27
- "type": "string",
28
- "name": "fizz",
29
- "id": 1,
30
- "options": {}
31
- }
32
- ],
33
- "enums": [],
34
- "messages": [],
35
- "options": {}
36
- }
37
- ],
38
- "enums": [],
39
- "imports": [],
40
- "options": {},
41
- "services": []
42
- }
43
- ],
44
- "options": {},
45
- "services": []
46
- }
1
+ {
2
+ "package": null,
3
+ "messages": [
4
+ {
5
+ "ref": "Foo",
6
+ "fields": [
7
+ {
8
+ "rule": "required",
9
+ "type": "string",
10
+ "name": "buzz",
11
+ "id": 2,
12
+ "options": {}
13
+ }
14
+ ]
15
+ }
16
+ ],
17
+ "enums": [],
18
+ "imports": [
19
+ {
20
+ "package": null,
21
+ "messages": [
22
+ {
23
+ "name": "Foo",
24
+ "fields": [
25
+ {
26
+ "rule": "required",
27
+ "type": "string",
28
+ "name": "fizz",
29
+ "id": 1,
30
+ "options": {}
31
+ }
32
+ ],
33
+ "enums": [],
34
+ "messages": [],
35
+ "options": {}
36
+ }
37
+ ],
38
+ "enums": [],
39
+ "imports": [],
40
+ "options": {},
41
+ "services": []
42
+ }
43
+ ],
44
+ "options": {},
45
+ "services": []
46
+ }
package/tests/suite.js CHANGED
@@ -20,7 +20,7 @@
20
20
  */
21
21
  (function(global) {
22
22
 
23
- var FILE = "ProtoBuf.js";
23
+ var FILE = "protobuf.js";
24
24
  var BROWSER = !!global.window;
25
25
  var StdOutFixture = require('fixture-stdout');
26
26
  var fixture = new StdOutFixture();
@@ -263,6 +263,36 @@
263
263
  test.deepEqual(t2, t3);
264
264
  test.done();
265
265
  },
266
+
267
+ "constructorWithOneofs": function(test) {
268
+ try {
269
+ var builder = ProtoBuf.loadProtoFile(__dirname+"/oneof.proto"),
270
+ MyOneOf = builder.build("MyOneOf"),
271
+ TOneOf = builder.lookup(".MyOneOf");
272
+ test.ok(TOneOf.getChild("my_oneof"));
273
+
274
+ var myOneOf = new MyOneOf();
275
+ test.strictEqual(myOneOf.my_oneof, null);
276
+ myOneOf.set("id", 1);
277
+ test.strictEqual(myOneOf.my_oneof, "id");
278
+ myOneOf.set("name", "me");
279
+ test.strictEqual(myOneOf.my_oneof, "name");
280
+ test.strictEqual(myOneOf.id, null);
281
+
282
+ var copy = new MyOneOf(myOneOf); // this line is what was failing
283
+ // Error: .MyOneOf#my_oneof is not a field: undefined
284
+
285
+ test.deepEqual(myOneOf, copy);
286
+
287
+ // Test same things are there
288
+ test.strictEqual(copy.my_oneof, "name");
289
+ test.strictEqual(copy.name, "me");
290
+ test.strictEqual(copy.id, null);
291
+ } catch (e) {
292
+ fail(e);
293
+ }
294
+ test.done();
295
+ },
266
296
 
267
297
  "numberFormats": function(test) {
268
298
  try {
@@ -396,7 +426,7 @@
396
426
  try {
397
427
  var builder = ProtoBuf.loadProto("message Image { required bytes data = 1; }"),
398
428
  Image = builder.build("Image"),
399
- data = fs.readFileSync(__dirname+"/../ProtoBuf.png"),
429
+ data = fs.readFileSync(__dirname+"/../protobuf.png"),
400
430
  image = new Image({ data: data }),
401
431
  bb = image.encode(),
402
432
  imageDec = Image.decode(bb),
@@ -674,6 +704,18 @@
674
704
  test.done();
675
705
  },
676
706
 
707
+ // Test error messages
708
+ "errorMessage": function(test) {
709
+ test.throws(function() {
710
+ var builder = ProtoBuf.loadJsonFile(__dirname+"/complex.json");
711
+ var Game = builder.build("Game");
712
+ var car = new Game.Cars.Car();
713
+ car.speed = "hello";
714
+ car.encode();
715
+ }, /Illegal value for speed/);
716
+ test.done();
717
+ },
718
+
677
719
  // Builder reused to add definitions from multiple sources
678
720
  "multiBuilder": function(test) {
679
721
  try {
@@ -914,6 +956,19 @@
914
956
  test.done();
915
957
  },
916
958
 
959
+ "weakImports": function(test) {
960
+ try {
961
+ var builder = ProtoBuf.loadProtoFile(__dirname+"/imports-weak.proto");
962
+ var root = builder.build();
963
+ } catch (e) {
964
+ test.ok(e.message.indexOf("unresolvable type reference") >= 0);
965
+ test.done();
966
+ return;
967
+ }
968
+ var e = new Error("Weak import was imported.");
969
+ fail(e);
970
+ },
971
+
917
972
  "importExtensions": function(test) {
918
973
  var x = "package x; \
919
974
  message Test { \
@@ -1046,82 +1101,51 @@
1046
1101
  "extend": function(test) {
1047
1102
  try {
1048
1103
  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
- "extensions": [
1071
- 2,
1072
- 536870911
1073
- ],
1074
- "oneofs": []
1075
- },
1076
- {
1077
- "ref": "Foo",
1078
- "fields":[
1079
- {
1080
- "rule": "optional",
1081
- "options": {},
1082
- "type": "string",
1083
- "name": "bar",
1084
- "id": 2
1085
- }
1086
- ]
1087
- },
1088
- {
1089
- "name": "Bar",
1090
- "fields": [],
1091
- "enums": [],
1092
- "messages": [
1093
- {
1094
- "name": "Foo",
1095
- "fields": [],
1096
- "enums": [],
1097
- "messages": [],
1098
- "options": {},
1099
- "oneofs": []
1100
- },
1101
- {
1102
- "ref": ".Foo",
1103
- "fields": [
1104
- {
1105
- "rule": "optional",
1106
- "options": {},
1107
- "type": "Foo",
1108
- "name": "foo",
1109
- "id": 3
1110
- }
1111
- ]
1112
- }
1113
- ],
1114
- "options": {},
1115
- "oneofs": []
1116
- }
1117
- ],
1118
- "enums": [],
1119
- "imports": [
1120
- "google/protobuf/descriptor.proto"
1121
- ],
1122
- "options": {},
1123
- "services": []
1124
- });
1104
+ test.deepEqual(ast, { package: null,
1105
+ messages:
1106
+ [ { ref: 'google.protobuf.MessageOptions',
1107
+ fields:
1108
+ [ { rule: 'optional',
1109
+ type: 'int32',
1110
+ name: 'foo',
1111
+ options: {},
1112
+ id: 1001 } ] },
1113
+ { name: 'Foo',
1114
+ fields: [],
1115
+ enums: [],
1116
+ messages: [],
1117
+ options: {},
1118
+ services: [],
1119
+ oneofs: {},
1120
+ extensions: [ [ 2, 536870911 ] ] },
1121
+ { ref: 'Foo',
1122
+ fields:
1123
+ [ { rule: 'optional',
1124
+ type: 'string',
1125
+ name: 'bar',
1126
+ options: {},
1127
+ id: 2 } ] },
1128
+ { name: 'Bar',
1129
+ fields: [],
1130
+ enums: [],
1131
+ messages:
1132
+ [ { name: 'Foo',
1133
+ fields: [],
1134
+ enums: [],
1135
+ messages: [],
1136
+ options: {},
1137
+ services: [],
1138
+ oneofs: {} },
1139
+ { ref: '.Foo',
1140
+ fields: [ { rule: 'optional', type: 'Foo', name: 'foo', options: {}, id: 3 } ] } ],
1141
+ options: {},
1142
+ services: [],
1143
+ oneofs: {} } ],
1144
+ enums: [],
1145
+ imports: [ 'google/protobuf/descriptor.proto' ],
1146
+ options: {},
1147
+ services: [] }
1148
+ );
1125
1149
 
1126
1150
  var builder = ProtoBuf.loadProtoFile(__dirname+"/extend.proto");
1127
1151
  var TFoo = builder.lookup(".Foo"),
@@ -1133,8 +1157,8 @@
1133
1157
  test.strictEqual(fields[0].id, 2);
1134
1158
  test.strictEqual(fields[1].name, ".Bar.foo");
1135
1159
  test.strictEqual(fields[1].id, 3);
1136
- test.deepEqual(TFoo.extensions, [2, ProtoBuf.ID_MAX]); // Defined
1137
- test.deepEqual(TBar.extensions, [ProtoBuf.ID_MIN, ProtoBuf.ID_MAX]); // Undefined
1160
+ test.deepEqual(TFoo.extensions, [[2, ProtoBuf.ID_MAX]]); // explicitly defined
1161
+ test.strictEqual(TBar.extensions, undefined); // none defined
1138
1162
  test.deepEqual(TBar.getChild("foo"), { builder: builder, parent: TBar, name: "foo", field: TFoo.getChild('.Bar.foo') });
1139
1163
  test.strictEqual(TBar.getChildren(ProtoBuf.Reflect.Message.Field).length, 0);
1140
1164
  var root = builder.build();
@@ -1272,7 +1296,8 @@
1272
1296
  },
1273
1297
 
1274
1298
  // Properly ignore "syntax" and "extensions" keywords
1275
- "gtfs-realtime": function(test) {
1299
+ // The corresponding .proto file has been removed upon request
1300
+ /* "gtfs-realtime": function(test) {
1276
1301
  try {
1277
1302
  test.doesNotThrow(function() {
1278
1303
  ProtoBuf.loadProtoFile(__dirname+"/gtfs-realtime.proto");
@@ -1281,7 +1306,7 @@
1281
1306
  fail(e);
1282
1307
  }
1283
1308
  test.done();
1284
- },
1309
+ }, */
1285
1310
 
1286
1311
  "delimited": function(test) {
1287
1312
  try {
package/ProtoBuf.png DELETED
Binary file
@@ -1,87 +0,0 @@
1
- /*
2
- ProtoBuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
- Released under the Apache License, Version 2.0
4
- see: https://github.com/dcodeIO/ProtoBuf.js for details
5
- */
6
- (function(h,x){"function"===typeof define&&define.amd?define(["ByteBuffer"],x):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=x(require("bytebuffer"),!0):(h.dcodeIO=h.dcodeIO||{}).ProtoBuf=x(h.dcodeIO.ByteBuffer)})(this,function(h,x){var c={};c.ByteBuffer=h;c.Long=h.Long||null;c.VERSION="4.1.2";c.WIRE_TYPES={};c.WIRE_TYPES.VARINT=0;c.WIRE_TYPES.BITS64=1;c.WIRE_TYPES.LDELIM=2;c.WIRE_TYPES.STARTGROUP=3;c.WIRE_TYPES.ENDGROUP=4;c.WIRE_TYPES.BITS32=5;c.PACKABLE_WIRE_TYPES=
7
- [c.WIRE_TYPES.VARINT,c.WIRE_TYPES.BITS64,c.WIRE_TYPES.BITS32];c.TYPES={int32:{name:"int32",wireType:c.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:c.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:c.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:c.WIRE_TYPES.VARINT,defaultValue:c.Long?c.Long.ZERO:void 0},uint64:{name:"uint64",wireType:c.WIRE_TYPES.VARINT,defaultValue:c.Long?c.Long.UZERO:void 0},sint64:{name:"sint64",wireType:c.WIRE_TYPES.VARINT,
8
- defaultValue:c.Long?c.Long.ZERO:void 0},bool:{name:"bool",wireType:c.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:c.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:c.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:c.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:c.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:c.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:c.WIRE_TYPES.BITS64,
9
- defaultValue:c.Long?c.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:c.WIRE_TYPES.BITS64,defaultValue:c.Long?c.Long.ZERO:void 0},"float":{name:"float",wireType:c.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:c.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:c.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:c.WIRE_TYPES.STARTGROUP,defaultValue:null}};c.MAP_KEY_TYPES=[c.TYPES.int32,c.TYPES.sint32,c.TYPES.sfixed32,c.TYPES.uint32,c.TYPES.fixed32,
10
- c.TYPES.int64,c.TYPES.sint64,c.TYPES.sfixed64,c.TYPES.uint64,c.TYPES.fixed64,c.TYPES.bool,c.TYPES.string,c.TYPES.bytes];c.ID_MIN=1;c.ID_MAX=536870911;c.convertFieldsToCamelCase=!1;c.populateAccessors=!0;c.populateDefaults=!0;c.Util=function(){var a={};a.IS_NODE=!("object"!==typeof process||"[object process]"!==process+""||process.browser);a.XHR=function(){for(var a=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},
11
- function(){return new ActiveXObject("Microsoft.XMLHTTP")}],c=null,h=0;h<a.length;h++){try{c=a[h]()}catch(l){continue}break}if(!c)throw Error("XMLHttpRequest is not supported");return c};a.fetch=function(c,h){h&&"function"!=typeof h&&(h=null);if(a.IS_NODE){var p=require("fs");if(h)p.readFile(c,function(a,c){a?h(null):h(""+c)});else try{return p.readFileSync(c)}catch(l){return null}}else{var g=a.XHR();g.open("GET",c,h?!0:!1);g.setRequestHeader("Accept","text/plain");"function"===typeof g.overrideMimeType&&
12
- g.overrideMimeType("text/plain");if(h)g.onreadystatechange=function(){4==g.readyState&&(200==g.status||0==g.status&&"string"===typeof g.responseText?h(g.responseText):h(null))},4!=g.readyState&&g.send(null);else return g.send(null),200==g.status||0==g.status&&"string"===typeof g.responseText?g.responseText:null}};a.toCamelCase=function(a){return a.replace(/_([a-zA-Z])/g,function(a,c){return c.toUpperCase()})};return a}();c.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,
13
- TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,
14
- BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g};c.Reflect=function(a){function c(b,e){if(b&&"number"===typeof b.low&&"number"===typeof b.high&&"boolean"===typeof b.unsigned&&b.low===b.low&&b.high===b.high)return new a.Long(b.low,b.high,"undefined"===
15
- typeof e?b.unsigned:e);if("string"===typeof b)return a.Long.fromString(b,e||!1,10);if("number"===typeof b)return a.Long.fromNumber(b,e||!1);throw Error("not convertible to Long");}function s(b,e){var m=e.readVarint32(),d=m&7,m=m>>>3;switch(d){case a.WIRE_TYPES.VARINT:do m=e.readUint8();while(128===(m&128));break;case a.WIRE_TYPES.BITS64:e.offset+=8;break;case a.WIRE_TYPES.LDELIM:m=e.readVarint32();e.offset+=m;break;case a.WIRE_TYPES.STARTGROUP:s(m,e);break;case a.WIRE_TYPES.ENDGROUP:if(m===b)return!1;
16
- throw Error("Illegal GROUPEND after unknown group: "+m+" ("+b+" expected)");case a.WIRE_TYPES.BITS32:e.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+b+": "+d);}return!0}var p={},l=function(b,e,a){this.builder=b;this.parent=e;this.name=a},g=l.prototype;g.fqn=function(){var b=this.name,e=this;do{e=e.parent;if(null==e)break;b=e.name+"."+b}while(1);return b};g.toString=function(b){return(b?this.className+" ":"")+this.fqn()};g.build=function(){throw Error(this.toString(!0)+
17
- " cannot be built directly");};p.T=l;var d=function(b,e,a,d,r){l.call(this,b,e,a);this.className="Namespace";this.children=[];this.options=d||{};this.syntax=r||"proto2"},g=d.prototype=Object.create(l.prototype);g.getChildren=function(b){b=b||null;if(null==b)return this.children.slice();for(var e=[],a=0,d=this.children.length;a<d;++a)this.children[a]instanceof b&&e.push(this.children[a]);return e};g.addChild=function(b){var e;if(e=this.getChild(b.name))if(e instanceof n.Field&&e.name!==e.originalName&&
18
- null===this.getChild(e.originalName))e.name=e.originalName;else if(b instanceof n.Field&&b.name!==b.originalName&&null===this.getChild(b.originalName))b.name=b.originalName;else throw Error("Duplicate name in namespace "+this.toString(!0)+": "+b.name);this.children.push(b)};g.getChild=function(b){for(var e="number"===typeof b?"id":"name",a=0,d=this.children.length;a<d;++a)if(this.children[a][e]===b)return this.children[a];return null};g.resolve=function(b,e){var a="string"===typeof b?b.split("."):
19
- b,d=this,r=0;if(""===a[r]){for(;null!==d.parent;)d=d.parent;r++}do{do{if(!(d instanceof p.Namespace)){d=null;break}d=d.getChild(a[r]);if(!(d&&d instanceof p.T)||e&&!(d instanceof p.Namespace)){d=null;break}r++}while(r<a.length);if(null!=d)break;if(null!==this.parent)return this.parent.resolve(b,e)}while(null!=d);return d};g.qn=function(b){var e=[],a=b;do e.unshift(a.name),a=a.parent;while(null!==a);for(a=1;a<=e.length;a++){var d=e.slice(e.length-a);if(b===this.resolve(d,b instanceof p.Namespace))return d.join(".")}return b.fqn()};
20
- g.build=function(){for(var b={},a=this.children,m=0,c=a.length,r;m<c;++m)r=a[m],r instanceof d&&(b[r.name]=r.build());Object.defineProperty&&Object.defineProperty(b,"$options",{value:this.buildOpt()});return b};g.buildOpt=function(){for(var b={},a=Object.keys(this.options),d=0,c=a.length;d<c;++d)b[a[d]]=this.options[a[d]];return b};g.getOption=function(b){return"undefined"===typeof b?this.options:"undefined"!==typeof this.options[b]?this.options[b]:null};p.Namespace=d;var k=function(b,e,d,c){this.type=
21
- b;this.resolvedType=e;this.isMapKey=d;this.syntax=c;if(d&&0>a.MAP_KEY_TYPES.indexOf(b))throw Error("Invalid map key type: "+b.name);},f=k.prototype;k.defaultFieldValue=function(b){"string"===typeof b&&(b=a.TYPES[b]);if("undefined"===typeof b.defaultValue)throw Error("default value for type "+b.name+" is not supported");return b==a.TYPES.bytes?new h(0):b.defaultValue};f.verifyValue=function(b){var e=function(b,a){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+b+
22
- " ("+a+")");}.bind(this);switch(this.type){case a.TYPES.int32:case a.TYPES.sint32:case a.TYPES.sfixed32:return("number"!==typeof b||b===b&&0!==b%1)&&e(typeof b,"not an integer"),4294967295<b?b|0:b;case a.TYPES.uint32:case a.TYPES.fixed32:return("number"!==typeof b||b===b&&0!==b%1)&&e(typeof b,"not an integer"),0>b?b>>>0:b;case a.TYPES.int64:case a.TYPES.sint64:case a.TYPES.sfixed64:if(a.Long)try{return c(b,!1)}catch(d){e(typeof b,d.message)}else e(typeof b,"requires Long.js");case a.TYPES.uint64:case a.TYPES.fixed64:if(a.Long)try{return c(b,
23
- !0)}catch(f){e(typeof b,f.message)}else e(typeof b,"requires Long.js");case a.TYPES.bool:return"boolean"!==typeof b&&e(typeof b,"not a boolean"),b;case a.TYPES["float"]:case a.TYPES["double"]:return"number"!==typeof b&&e(typeof b,"not a number"),b;case a.TYPES.string:return"string"===typeof b||b&&b instanceof String||e(typeof b,"not a string"),""+b;case a.TYPES.bytes:return h.isByteBuffer(b)?b:h.wrap(b,"base64");case a.TYPES["enum"]:for(var r=this.resolvedType.getChildren(a.Reflect.Enum.Value),t=
24
- 0;t<r.length;t++)if(r[t].name==b||r[t].id==b)return r[t].id;if("proto3"===this.syntax)return("number"!==typeof b||b===b&&0!==b%1)&&e(typeof b,"not an integer"),(4294967295<b||0>b)&&e(typeof b,"not in range for uint32"),b;e(b,"not a valid enum value");case a.TYPES.group:case a.TYPES.message:b&&"object"===typeof b||e(typeof b,"object expected");if(b instanceof this.resolvedType.clazz)return b;if(b instanceof a.Builder.Message){var e={},t;for(t in b)b.hasOwnProperty(t)&&(e[t]=b[t]);b=e}return new this.resolvedType.clazz(b)}throw Error("[INTERNAL] Illegal value for "+
25
- this.toString(!0)+": "+b+" (undefined type "+this.type+")");};f.calculateLength=function(b,e){if(null===e)return 0;var d;switch(this.type){case a.TYPES.int32:return 0>e?h.calculateVarint64(e):h.calculateVarint32(e);case a.TYPES.uint32:return h.calculateVarint32(e);case a.TYPES.sint32:return h.calculateVarint32(h.zigZagEncode32(e));case a.TYPES.fixed32:case a.TYPES.sfixed32:case a.TYPES["float"]:return 4;case a.TYPES.int64:case a.TYPES.uint64:return h.calculateVarint64(e);case a.TYPES.sint64:return h.calculateVarint64(h.zigZagEncode64(e));
26
- case a.TYPES.fixed64:case a.TYPES.sfixed64:return 8;case a.TYPES.bool:return 1;case a.TYPES["enum"]:return h.calculateVarint32(e);case a.TYPES["double"]:return 8;case a.TYPES.string:return d=h.calculateUTF8Bytes(e),h.calculateVarint32(d)+d;case a.TYPES.bytes:if(0>e.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+e.remaining()+" bytes remaining");return h.calculateVarint32(e.remaining())+e.remaining();case a.TYPES.message:return d=this.resolvedType.calculate(e),h.calculateVarint32(d)+
27
- d;case a.TYPES.group:return d=this.resolvedType.calculate(e),d+h.calculateVarint32(b<<3|a.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+e+" (unknown type)");};f.encodeValue=function(b,e,d){if(null===e)return d;switch(this.type){case a.TYPES.int32:0>e?d.writeVarint64(e):d.writeVarint32(e);break;case a.TYPES.uint32:d.writeVarint32(e);break;case a.TYPES.sint32:d.writeVarint32ZigZag(e);break;case a.TYPES.fixed32:d.writeUint32(e);break;case a.TYPES.sfixed32:d.writeInt32(e);
28
- break;case a.TYPES.int64:case a.TYPES.uint64:d.writeVarint64(e);break;case a.TYPES.sint64:d.writeVarint64ZigZag(e);break;case a.TYPES.fixed64:d.writeUint64(e);break;case a.TYPES.sfixed64:d.writeInt64(e);break;case a.TYPES.bool:"string"===typeof e?d.writeVarint32("false"===e.toLowerCase()?0:!!e):d.writeVarint32(e?1:0);break;case a.TYPES["enum"]:d.writeVarint32(e);break;case a.TYPES["float"]:d.writeFloat32(e);break;case a.TYPES["double"]:d.writeFloat64(e);break;case a.TYPES.string:d.writeVString(e);
29
- break;case a.TYPES.bytes:if(0>e.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+e.remaining()+" bytes remaining");b=e.offset;d.writeVarint32(e.remaining());d.append(e);e.offset=b;break;case a.TYPES.message:b=(new h).LE();this.resolvedType.encode(e,b);d.writeVarint32(b.offset);d.append(b.flip());break;case a.TYPES.group:this.resolvedType.encode(e,d);d.writeVarint32(b<<3|a.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+
30
- e+" (unknown type)");}return d};f.decode=function(b,e,d){if(e!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case a.TYPES.int32:return b.readVarint32()|0;case a.TYPES.uint32:return b.readVarint32()>>>0;case a.TYPES.sint32:return b.readVarint32ZigZag()|0;case a.TYPES.fixed32:return b.readUint32()>>>0;case a.TYPES.sfixed32:return b.readInt32()|0;case a.TYPES.int64:return b.readVarint64();case a.TYPES.uint64:return b.readVarint64().toUnsigned();case a.TYPES.sint64:return b.readVarint64ZigZag();
31
- case a.TYPES.fixed64:return b.readUint64();case a.TYPES.sfixed64:return b.readInt64();case a.TYPES.bool:return!!b.readVarint32();case a.TYPES["enum"]:return b.readVarint32();case a.TYPES["float"]:return b.readFloat();case a.TYPES["double"]:return b.readDouble();case a.TYPES.string:return b.readVString();case a.TYPES.bytes:d=b.readVarint32();if(b.remaining()<d)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+d+" required but got only "+b.remaining());e=b.clone();e.limit=e.offset+d;
32
- b.offset+=d;return e;case a.TYPES.message:return d=b.readVarint32(),this.resolvedType.decode(b,d);case a.TYPES.group:return this.resolvedType.decode(b,-1,d)}throw Error("[INTERNAL] Illegal decode type");};f.valueFromString=function(b){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case a.TYPES.int32:case a.TYPES.sint32:case a.TYPES.sfixed32:case a.TYPES.uint32:case a.TYPES.fixed32:return this.verifyValue(parseInt(b));case a.TYPES.int64:case a.TYPES.sint64:case a.TYPES.sfixed64:case a.TYPES.uint64:case a.TYPES.fixed64:return this.verifyValue(b);
33
- case a.TYPES.bool:return"true"===b;case a.TYPES.string:return this.verifyValue(b);case a.TYPES.bytes:return h.fromBinary(b)}};f.valueToString=function(b){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===a.TYPES.bytes?b.toString("binary"):b.toString()};p.Element=k;var n=function(b,e,c,f,r,t){d.call(this,b,e,c,f,t);this.className="Message";this.extensions=[a.ID_MIN,a.ID_MAX];this.clazz=null;this.isGroup=!!r;this._fieldsByName=this._fieldsById=this._fields=
34
- null},f=n.prototype=Object.create(d.prototype);f.build=function(b){if(this.clazz&&!b)return this.clazz;b=function(b,a){function e(a,d,c,f){if(null===a||"object"!==typeof a){if(f&&f instanceof b.Reflect.Enum){var m=b.Reflect.Enum.getName(f.object,a);if(null!==m)return m}return a}if(h.isByteBuffer(a))return d?a.toBase64():a.toBuffer();if(b.Long.isLong(a))return c?a.toString():new b.Long(a);var g;if(Array.isArray(a))return g=[],a.forEach(function(b,a){g[a]=e(b,d,c,f)}),g;g={};if(a instanceof b.Map){for(var m=
35
- a.entries(),k=m.next();!k.done;k=m.next())g[a.keyElem.valueToString(k.value[0])]=e(k.value[1],d,c,a.valueElem.resolvedType);return g}var m=a.$type,k=void 0,n;for(n in a)a.hasOwnProperty(n)&&(m&&(k=m.getChild(n))?g[n]=e(a[n],d,c,k.resolvedType):g[n]=e(a[n],d,c));return g}var d=a.getChildren(b.Reflect.Message.Field),c=a.getChildren(b.Reflect.Message.OneOf),m=function(e,f){b.Builder.Message.call(this);for(var g=0,k=c.length;g<k;++g)this[c[g].name]=null;g=0;for(k=d.length;g<k;++g){var n=d[g];this[n.name]=
36
- n.repeated?[]:n.map?new b.Map(n):null;!n.required&&"proto3"!==a.syntax||null===n.defaultValue||(this[n.name]=n.defaultValue)}if(0<arguments.length)if(1!==arguments.length||null===e||"object"!==typeof e||!("function"!==typeof e.encode||e instanceof m)||Array.isArray(e)||e instanceof b.Map||h.isByteBuffer(e)||e instanceof ArrayBuffer||b.Long&&e instanceof b.Long)for(g=0,k=arguments.length;g<k;++g)"undefined"!==typeof(n=arguments[g])&&this.$set(d[g].name,n);else this.$set(e)},f=m.prototype=Object.create(b.Builder.Message.prototype);
37
- f.add=function(e,d,c){var f=a._fieldsByName[e];if(!c){if(!f)throw Error(this+"#"+e+" is undefined");if(!(f instanceof b.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+f.toString(!0));if(!f.repeated)throw Error(this+"#"+e+" is not a repeated field");d=f.verifyValue(d,!0)}null===this[e]&&(this[e]=[]);this[e].push(d);return this};f.$add=f.add;f.set=function(e,d,f){if(e&&"object"===typeof e){f=d;for(var c in e)e.hasOwnProperty(c)&&"undefined"!==typeof(d=e[c])&&this.$set(c,d,f);return this}c=
38
- a._fieldsByName[e];if(f)this[e]=d;else{if(!c)throw Error(this+"#"+e+" is not a field: undefined");if(!(c instanceof b.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+c.toString(!0));this[c.name]=d=c.verifyValue(d)}c&&c.oneof&&(f=this[c.oneof.name],null!==d?(null!==f&&f!==c.name&&(this[f]=null),this[c.oneof.name]=c.name):f===e&&(this[c.oneof.name]=null));return this};f.$set=f.set;f.get=function(e,d){if(d)return this[e];var c=a._fieldsByName[e];if(!(c&&c instanceof b.Reflect.Message.Field))throw Error(this+
39
- "#"+e+" is not a field: undefined");if(!(c instanceof b.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+c.toString(!0));return this[c.name]};f.$get=f.get;for(var g=0;g<d.length;g++){var k=d[g];k instanceof b.Reflect.Message.ExtensionField||a.builder.options.populateAccessors&&function(b){var e=b.originalName.replace(/(_[a-zA-Z])/g,function(b){return b.toUpperCase().replace("_","")}),e=e.substring(0,1).toUpperCase()+e.substring(1),d=b.originalName.replace(/([A-Z])/g,function(b){return"_"+
40
- b}),c=function(a,e){this[b.name]=e?a:b.verifyValue(a);return this},m=function(){return this[b.name]};null===a.getChild("set"+e)&&(f["set"+e]=c);null===a.getChild("set_"+d)&&(f["set_"+d]=c);null===a.getChild("get"+e)&&(f["get"+e]=m);null===a.getChild("get_"+d)&&(f["get_"+d]=m)}(k)}f.encode=function(b,e){"boolean"===typeof b&&(e=b,b=void 0);var d=!1;b||(b=new h,d=!0);var c=b.littleEndian;try{return a.encode(this,b.LE(),e),(d?b.flip():b).LE(c)}catch(f){throw b.LE(c),f;}};m.encode=function(b,a,e){return(new m(b)).encode(a,
41
- e)};f.calculate=function(){return a.calculate(this)};f.encodeDelimited=function(b){var e=!1;b||(b=new h,e=!0);var d=(new h).LE();a.encode(this,d).flip();b.writeVarint32(d.remaining());b.append(d);return e?b.flip():b};f.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(b){throw b.encoded&&(b.encoded=b.encoded.toArrayBuffer()),b;}};f.toArrayBuffer=f.encodeAB;f.encodeNB=function(){try{return this.encode().toBuffer()}catch(b){throw b.encoded&&(b.encoded=b.encoded.toBuffer()),b;}};f.toBuffer=
42
- f.encodeNB;f.encode64=function(){try{return this.encode().toBase64()}catch(b){throw b.encoded&&(b.encoded=b.encoded.toBase64()),b;}};f.toBase64=f.encode64;f.encodeHex=function(){try{return this.encode().toHex()}catch(b){throw b.encoded&&(b.encoded=b.encoded.toHex()),b;}};f.toHex=f.encodeHex;f.toRaw=function(b,a){return e(this,!!b,!!a,this.$type)};f.encodeJSON=function(){return JSON.stringify(e(this,!0,!0,this.$type))};m.decode=function(b,e){"string"===typeof b&&(b=h.wrap(b,e?e:"base64"));b=h.isByteBuffer(b)?
43
- b:h.wrap(b);var d=b.littleEndian;try{var c=a.decode(b.LE());b.LE(d);return c}catch(f){throw b.LE(d),f;}};m.decodeDelimited=function(b,e){"string"===typeof b&&(b=h.wrap(b,e?e:"base64"));b=h.isByteBuffer(b)?b:h.wrap(b);if(1>b.remaining())return null;var d=b.offset,c=b.readVarint32();if(b.remaining()<c)return b.offset=d,null;try{var f=a.decode(b.slice(b.offset,b.offset+c).LE());b.offset+=c;return f}catch(m){throw b.offset+=c,m;}};m.decode64=function(b){return m.decode(b,"base64")};m.decodeHex=function(b){return m.decode(b,
44
- "hex")};m.decodeJSON=function(b){return new m(JSON.parse(b))};f.toString=function(){return a.toString()};Object.defineProperty&&(Object.defineProperty(m,"$options",{value:a.buildOpt()}),Object.defineProperty(f,"$options",{value:m.$options}),Object.defineProperty(m,"$type",{value:a}),Object.defineProperty(f,"$type",{value:a}));return m}(a,this);this._fields=[];this._fieldsById={};this._fieldsByName={};for(var e=0,d=this.children.length,c;e<d;e++)if(c=this.children[e],c instanceof w||c instanceof n||
45
- c instanceof z){if(b.hasOwnProperty(c.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+c.toString(!0)+" cannot override static property '"+c.name+"'");b[c.name]=c.build()}else if(c instanceof n.Field)c.build(),this._fields.push(c),this._fieldsById[c.id]=c,this._fieldsByName[c.name]=c;else if(!(c instanceof n.OneOf||c instanceof v))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[e].toString(!0));return this.clazz=b};f.encode=function(b,a,d){for(var c=
46
- null,f,g=0,k=this._fields.length,n;g<k;++g)f=this._fields[g],n=b[f.name],f.required&&null===n?null===c&&(c=f):f.encode(d?n:f.verifyValue(n),a,b);if(null!==c)throw b=Error("Missing at least one required field for "+this.toString(!0)+": "+c),b.encoded=a,b;return a};f.calculate=function(b){for(var a=0,d=0,c=this._fields.length,f,g;d<c;++d){f=this._fields[d];g=b[f.name];if(f.required&&null===g)throw Error("Missing at least one required field for "+this.toString(!0)+": "+f);a+=f.calculate(g,b)}return a};
47
- f.decode=function(b,e,d){e="number"===typeof e?e:-1;for(var c=b.offset,f=new this.clazz,g,k,n;b.offset<c+e||-1===e&&0<b.remaining();){g=b.readVarint32();k=g&7;n=g>>>3;if(k===a.WIRE_TYPES.ENDGROUP){if(n!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+n+" ("+(d?d+" expected":"not a group")+")");break}if(g=this._fieldsById[n])g.repeated&&!g.options.packed?f[g.name].push(g.decode(k,b)):g.map?(k=g.decode(k,b),f[g.name].set(k[0],k[1])):(f[g.name]=g.decode(k,b),g.oneof&&(k=f[g.oneof.name],
48
- null!==k&&k!==g.name&&(f[k]=null),f[g.oneof.name]=g.name));else switch(k){case a.WIRE_TYPES.VARINT:b.readVarint32();break;case a.WIRE_TYPES.BITS32:b.offset+=4;break;case a.WIRE_TYPES.BITS64:b.offset+=8;break;case a.WIRE_TYPES.LDELIM:g=b.readVarint32();b.offset+=g;break;case a.WIRE_TYPES.STARTGROUP:for(;s(n,b););break;default:throw Error("Illegal wire type for unknown field "+n+" in "+this.toString(!0)+"#decode: "+k);}}b=0;for(e=this._fields.length;b<e;++b)if(g=this._fields[b],null===f[g.name])if("proto3"===
49
- this.syntax)f[g.name]=g.defaultValue;else{if(g.required)throw b=Error("Missing at least one required field for "+this.toString(!0)+": "+g.name),b.decoded=f,b;a.populateDefaults&&null!==g.defaultValue&&(f[g.name]=g.defaultValue)}return f};p.Message=n;var y=function(b,e,d,c,f,g,k,v,h,q){l.call(this,b,e,g);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;this.map="map"===d;this.keyType=c||null;this.type=f;this.resolvedType=null;this.id=k;this.options=v||{};this.defaultValue=
50
- null;this.oneof=h||null;this.syntax=q||"proto2";this.originalName=this.name;this.keyElement=this.element=null;!this.builder.options.convertFieldsToCamelCase||this instanceof n.ExtensionField||(this.name=a.Util.toCamelCase(this.name))},f=y.prototype=Object.create(l.prototype);f.build=function(){this.element=new k(this.type,this.resolvedType,!1,this.syntax);this.map&&(this.keyElement=new k(this.keyType,void 0,!0,this.syntax));"proto3"!==this.syntax||this.repeated||this.map?"undefined"!==typeof this.options["default"]&&
51
- (this.defaultValue=this.verifyValue(this.options["default"])):this.defaultValue=k.defaultFieldValue(this.type)};f.verifyValue=function(b,e){e=e||!1;var d=function(b,a){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+b+" ("+a+")");}.bind(this);if(null===b)return this.required&&d(typeof b,"required"),"proto3"===this.syntax&&this.type!==a.TYPES.message&&d(typeof b,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!e){Array.isArray(b)||(b=
52
- [b]);for(var c=[],d=0;d<b.length;d++)c.push(this.element.verifyValue(b[d]));return c}if(this.map&&!e){if(b instanceof a.Map)return b;b instanceof Object||d(typeof b,"expected ProtoBuf.Map or raw object for map field");return new a.Map(this,b)}!this.repeated&&Array.isArray(b)&&d(typeof b,"no array expected");return this.element.verifyValue(b)};f.hasWirePresence=function(b,e){if("proto3"!==this.syntax)return null!==b;if(this.oneof&&e[this.oneof.name]===this.name)return!0;switch(this.type){case a.TYPES.int32:case a.TYPES.sint32:case a.TYPES.sfixed32:case a.TYPES.uint32:case a.TYPES.fixed32:return 0!==
53
- b;case a.TYPES.int64:case a.TYPES.sint64:case a.TYPES.sfixed64:case a.TYPES.uint64:case a.TYPES.fixed64:return 0!==b.low||0!==b.high;case a.TYPES.bool:return b;case a.TYPES["float"]:case a.TYPES["double"]:return 0!==b;case a.TYPES.string:return 0<b.length;case a.TYPES.bytes:return 0<b.remaining();case a.TYPES["enum"]:return 0!==b;case a.TYPES.message:return null!==b;default:return!0}};f.encode=function(b,e,d){if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+
54
- this.toString(!0)+": "+this.type);if(null===b||this.repeated&&0==b.length)return e;try{if(this.repeated){var c;if(this.options.packed&&0<=a.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){e.writeVarint32(this.id<<3|a.WIRE_TYPES.LDELIM);e.ensureCapacity(e.offset+=1);var f=e.offset;for(c=0;c<b.length;c++)this.element.encodeValue(this.id,b[c],e);var g=e.offset-f,k=h.calculateVarint32(g);if(1<k){var n=e.slice(f,e.offset),f=f+(k-1);e.offset=f;e.append(n)}e.writeVarint32(g,f-k)}else for(c=0;c<b.length;c++)e.writeVarint32(this.id<<
55
- 3|this.type.wireType),this.element.encodeValue(this.id,b[c],e)}else this.map?b.forEach(function(b,d,c){c=h.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,d)+h.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,b);e.writeVarint32(this.id<<3|a.WIRE_TYPES.LDELIM);e.writeVarint32(c);e.writeVarint32(8|this.keyType.wireType);this.keyElement.encodeValue(1,d,e);e.writeVarint32(16|this.type.wireType);this.element.encodeValue(2,b,e)},this):this.hasWirePresence(b,
56
- d)&&(e.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,b,e))}catch(v){throw Error("Illegal value for "+this.toString(!0)+": "+b+" ("+v+")");}return e};f.calculate=function(b,d){b=this.verifyValue(b);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===b||this.repeated&&0==b.length)return 0;var c=0;try{if(this.repeated){var f,g;if(this.options.packed&&0<=a.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){c+=
57
- h.calculateVarint32(this.id<<3|a.WIRE_TYPES.LDELIM);for(f=g=0;f<b.length;f++)g+=this.element.calculateLength(this.id,b[f]);c+=h.calculateVarint32(g);c+=g}else for(f=0;f<b.length;f++)c+=h.calculateVarint32(this.id<<3|this.type.wireType),c+=this.element.calculateLength(this.id,b[f])}else this.map?b.forEach(function(b,d,e){b=h.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,d)+h.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,b);c+=h.calculateVarint32(this.id<<
58
- 3|a.WIRE_TYPES.LDELIM);c+=h.calculateVarint32(b);c+=b},this):this.hasWirePresence(b,d)&&(c+=h.calculateVarint32(this.id<<3|this.type.wireType),c+=this.element.calculateLength(this.id,b))}catch(k){throw Error("Illegal value for "+this.toString(!0)+": "+b+" ("+k+")");}return c};f.decode=function(b,d,c){if(!(!this.map&&b==this.type.wireType||!c&&this.repeated&&this.options.packed&&b==a.WIRE_TYPES.LDELIM||this.map&&b==a.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+
59
- b+" ("+this.type.wireType+" expected)");if(b==a.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=a.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!c){b=d.readVarint32();b=d.offset+b;for(c=[];d.offset<b;)c.push(this.decode(this.type.wireType,d,!0));return c}if(this.map){var f=k.defaultFieldValue(this.keyType);c=k.defaultFieldValue(this.type);b=d.readVarint32();if(d.remaining()<b)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+b+" required but got only "+d.remaining());
60
- var g=d.clone();g.limit=g.offset+b;for(d.offset+=b;0<g.remaining();)if(d=g.readVarint32(),b=d&7,d>>>=3,1===d)f=this.keyElement.decode(g,b,d);else if(2===d)c=this.element.decode(g,b,d);else throw Error("Unexpected tag in map field key/value submessage");return[f,c]}return this.element.decode(d,b,this.id)};p.Message.Field=y;f=function(b,d,a,c,f,g,k){y.call(this,b,d,a,null,c,f,g,k)};f.prototype=Object.create(y.prototype);p.Message.ExtensionField=f;p.Message.OneOf=function(b,d,a){l.call(this,b,d,a);this.fields=
61
- []};var w=function(b,a,c,f,g){d.call(this,b,a,c,f,g);this.className="Enum";this.object=null};w.getName=function(b,a){for(var d=Object.keys(b),c=0,f;c<d.length;++c)if(b[f=d[c]]===a)return f;return null};(w.prototype=Object.create(d.prototype)).build=function(b){if(this.object&&!b)return this.object;b=new a.Builder.Enum;for(var d=this.getChildren(w.Value),c=0,f=d.length;c<f;++c)b[d[c].name]=d[c].id;Object.defineProperty&&Object.defineProperty(b,"$options",{value:this.buildOpt(),enumerable:!1});return this.object=
62
- b};p.Enum=w;f=function(b,d,a,c){l.call(this,b,d,a);this.className="Enum.Value";this.id=c};f.prototype=Object.create(l.prototype);p.Enum.Value=f;var v=function(b,d,a,c){l.call(this,b,d,a);this.field=c};v.prototype=Object.create(l.prototype);p.Extension=v;var z=function(b,a,c,f){d.call(this,b,a,c,f);this.className="Service";this.clazz=null};(z.prototype=Object.create(d.prototype)).build=function(b){return this.clazz&&!b?this.clazz:this.clazz=function(b,d){for(var a=function(a){b.Builder.Service.call(this);
63
- this.rpcImpl=a||function(b,a,d){setTimeout(d.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},c=a.prototype=Object.create(b.Builder.Service.prototype),f=d.getChildren(b.Reflect.Service.RPCMethod),g=0;g<f.length;g++)(function(b){c[b.name]=function(a,c){try{try{a=b.resolvedRequestType.clazz.decode(h.wrap(a))}catch(e){if(!(e instanceof TypeError))throw e;}if(null===a||"object"!==typeof a)throw Error("Illegal arguments");a instanceof b.resolvedRequestType.clazz||
64
- (a=new b.resolvedRequestType.clazz(a));this.rpcImpl(b.fqn(),a,function(a,e){if(a)c(a);else{try{e=b.resolvedResponseType.clazz.decode(e)}catch(f){}e&&e instanceof b.resolvedResponseType.clazz?c(null,e):c(Error("Illegal response type received in service method "+d.name+"#"+b.name))}})}catch(f){setTimeout(c.bind(this,f),0)}};a[b.name]=function(d,c,e){(new a(d))[b.name](c,e)};Object.defineProperty&&(Object.defineProperty(a[b.name],"$options",{value:b.buildOpt()}),Object.defineProperty(c[b.name],"$options",
65
- {value:a[b.name].$options}))})(f[g]);Object.defineProperty&&(Object.defineProperty(a,"$options",{value:d.buildOpt()}),Object.defineProperty(c,"$options",{value:a.$options}),Object.defineProperty(a,"$type",{value:d}),Object.defineProperty(c,"$type",{value:d}));return a}(a,this)};p.Service=z;var u=function(b,a,d,c){l.call(this,b,a,d);this.className="Service.Method";this.options=c||{}};(u.prototype=Object.create(l.prototype)).buildOpt=g.buildOpt;p.Service.Method=u;g=function(b,a,d,c,f,g,k,n){u.call(this,
66
- b,a,d,n);this.className="Service.RPCMethod";this.requestName=c;this.responseName=f;this.requestStream=g;this.responseStream=k;this.resolvedResponseType=this.resolvedRequestType=null};g.prototype=Object.create(u.prototype);p.Service.RPCMethod=g;return p}(c);c.Builder=function(a,c,h){function p(a){a.messages&&a.messages.forEach(function(c){c.syntax=a.syntax;p(c)});a.enums&&a.enums.forEach(function(c){c.syntax=a.syntax})}var l=function(a){this.ptr=this.ns=new h.Namespace(this,null,"");this.resolved=
67
- !1;this.result=null;this.files={};this.importRoot=null;this.options=a||{}},g=l.prototype;l.isMessage=function(a){return"string"!==typeof a.name||"undefined"!==typeof a.values||"undefined"!==typeof a.rpc?!1:!0};l.isMessageField=function(a){return"string"!==typeof a.rule||"string"!==typeof a.name||"string"!==typeof a.type||"undefined"===typeof a.id?!1:!0};l.isEnum=function(a){return"string"===typeof a.name&&"undefined"!==typeof a.values&&Array.isArray(a.values)&&0!==a.values.length?!0:!1};l.isService=
68
- function(a){return"string"===typeof a.name&&"object"===typeof a.rpc&&a.rpc?!0:!1};l.isExtend=function(a){return"string"!==typeof a.ref?!1:!0};g.reset=function(){this.ptr=this.ns;return this};g.define=function(a){if("string"!==typeof a||!c.TYPEREF.test(a))throw Error("illegal namespace: "+a);a.split(".").forEach(function(a){var d=this.ptr.getChild(a);null===d&&this.ptr.addChild(d=new h.Namespace(this,this.ptr,a));this.ptr=d},this);return this};g.create=function(d){if(!d)return this;if(Array.isArray(d)){if(0===
69
- d.length)return this;d=d.slice()}else d=[d];for(var c=[d];0<c.length;){d=c.pop();if(!Array.isArray(d))throw Error("not a valid namespace: "+JSON.stringify(d));for(;0<d.length;){var f=d.shift();if(l.isMessage(f)){var g=new h.Message(this,this.ptr,f.name,f.options,f.isGroup,f.syntax),p={};f.oneofs&&Object.keys(f.oneofs).forEach(function(a){g.addChild(p[a]=new h.Message.OneOf(this,g,a))},this);f.fields&&f.fields.forEach(function(a){if(null!==g.getChild(a.id|0))throw Error("duplicate or invalid field id in "+
70
- g.name+": "+a.id);if(a.options&&"object"!==typeof a.options)throw Error("illegal field options in "+g.name+"#"+a.name);var d=null;if("string"===typeof a.oneof&&!(d=p[a.oneof]))throw Error("illegal oneof in "+g.name+"#"+a.name+": "+a.oneof);a=new h.Message.Field(this,g,a.rule,a.keytype,a.type,a.name,a.id,a.options,d,f.syntax);d&&d.fields.push(a);g.addChild(a)},this);var q=[];f.enums&&f.enums.forEach(function(a){q.push(a)});f.messages&&f.messages.forEach(function(a){q.push(a)});f.services&&f.services.forEach(function(a){q.push(a)});
71
- f.extensions&&(g.extensions=f.extensions,g.extensions[0]<a.ID_MIN&&(g.extensions[0]=a.ID_MIN),g.extensions[1]>a.ID_MAX&&(g.extensions[1]=a.ID_MAX));this.ptr.addChild(g);if(0<q.length){c.push(d);d=q;q=null;this.ptr=g;g=null;continue}q=null}else if(l.isEnum(f))g=new h.Enum(this,this.ptr,f.name,f.options,f.syntax),f.values.forEach(function(a){g.addChild(new h.Enum.Value(this,g,a.name,a.id))},this),this.ptr.addChild(g);else if(l.isService(f))g=new h.Service(this,this.ptr,f.name,f.options),Object.keys(f.rpc).forEach(function(a){var d=
72
- f.rpc[a];g.addChild(new h.Service.RPCMethod(this,g,a,d.request,d.response,!!d.request_stream,!!d.response_stream,d.options))},this),this.ptr.addChild(g);else if(l.isExtend(f))if(g=this.ptr.resolve(f.ref,!0))f.fields.forEach(function(d){if(null!==g.getChild(d.id|0))throw Error("duplicate extended field id in "+g.name+": "+d.id);if(d.id<g.extensions[0]||d.id>g.extensions[1])throw Error("illegal extended field id in "+g.name+": "+d.id+" ("+g.extensions.join(" to ")+" expected)");var c=d.name;this.options.convertFieldsToCamelCase&&
73
- (c=a.Util.toCamelCase(c));c=new h.Message.ExtensionField(this,g,d.rule,d.type,this.ptr.fqn()+"."+c,d.id,d.options);d=new h.Extension(this,this.ptr,d.name,c);c.extension=d;this.ptr.addChild(d);g.addChild(c)},this);else{if(!/\.?google\.protobuf\./.test(f.ref))throw Error("extended message "+f.ref+" is not defined");}else throw Error("not a valid definition: "+JSON.stringify(f));g=f=null}d=null;this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};g["import"]=function(d,c){var f="/";
74
- if("string"===typeof c){a.Util.IS_NODE&&(c=require("path").resolve(c));if(!0===this.files[c])return this.reset();this.files[c]=!0}else if("object"===typeof c){var g=c.root;a.Util.IS_NODE&&(g=require("path").resolve(g));if(0<=g.indexOf("\\")||0<=c.file.indexOf("\\"))f="\\";g=g+f+c.file;if(!0===this.files[g])return this.reset();this.files[g]=!0}if(d.imports&&0<d.imports.length){var h=!1;if("object"===typeof c){if(this.importRoot=c.root,h=!0,g=this.importRoot,c=c.file,0<=g.indexOf("\\")||0<=c.indexOf("\\"))f=
75
- "\\"}else"string"===typeof c?this.importRoot?g=this.importRoot:0<=c.indexOf("/")?(g=c.replace(/\/[^\/]*$/,""),""===g&&(g="/")):0<=c.indexOf("\\")?(g=c.replace(/\\[^\\]*$/,""),f="\\"):g=".":g=null;for(var l=0;l<d.imports.length;l++)if("string"===typeof d.imports[l]){if(!g)throw Error("cannot determine import root");var q=d.imports[l];if("google/protobuf/descriptor.proto"!==q&&(q=g+f+q,!0!==this.files[q])){/\.proto$/i.test(q)&&!a.DotProto&&(q=q.replace(/\.proto$/,".json"));var s=a.Util.fetch(q);if(null===
76
- s)throw Error("failed to import '"+q+"' in '"+c+"': file not found");if(/\.json$/i.test(q))this["import"](JSON.parse(s+""),q);else this["import"](a.DotProto.Parser.parse(s),q)}}else if(c)if(/\.(\w+)$/.test(c))this["import"](d.imports[l],c.replace(/^(.+)\.(\w+)$/,function(b,a,d){return a+"_import"+l+"."+d}));else this["import"](d.imports[l],c+"_import"+l);else this["import"](d.imports[l]);h&&(this.importRoot=null)}d["package"]&&this.define(d["package"]);d.syntax&&p(d);var u=this.ptr;d.options&&Object.keys(d.options).forEach(function(b){u.options[b]=
77
- d.options[b]});d.messages&&(this.create(d.messages),this.ptr=u);d.enums&&(this.create(d.enums),this.ptr=u);d.services&&(this.create(d.services),this.ptr=u);d["extends"]&&this.create(d["extends"]);return this.reset()};g.resolveAll=function(){var d;if(null==this.ptr||"object"===typeof this.ptr.type)return this;if(this.ptr instanceof h.Namespace)this.ptr.children.forEach(function(a){this.ptr=a;this.resolveAll()},this);else if(this.ptr instanceof h.Message.Field){if(c.TYPE.test(this.ptr.type))this.ptr.type=
78
- a.TYPES[this.ptr.type];else{if(!c.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);d=(this.ptr instanceof h.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0);if(!d)throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=d;if(d instanceof h.Enum){if(this.ptr.type=a.TYPES["enum"],"proto3"===this.ptr.syntax&&"proto3"!==d.syntax)throw Error("proto3 message cannot reference proto2 enum");
79
- }else if(d instanceof h.Message)this.ptr.type=d.isGroup?a.TYPES.group:a.TYPES.message;else throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}if(this.ptr.map){if(!c.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=a.TYPES[this.ptr.keyType]}}else if(this.ptr instanceof a.Reflect.Service.Method)if(this.ptr instanceof a.Reflect.Service.RPCMethod){d=this.ptr.parent.resolve(this.ptr.requestName,
80
- !0);if(!(d&&d instanceof a.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=d;d=this.ptr.parent.resolve(this.ptr.responseName,!0);if(!(d&&d instanceof a.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=d}else throw Error("illegal service type in "+this.ptr.toString(!0));else if(!(this.ptr instanceof a.Reflect.Message.OneOf||
81
- this.ptr instanceof a.Reflect.Extension||this.ptr instanceof a.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()};g.build=function(a){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null===this.result&&(this.result=this.ns.build());if(!a)return this.result;a="string"===typeof a?a.split("."):a;for(var c=this.result,g=0;g<a.length;g++)if(c[a[g]])c=c[a[g]];else{c=null;break}return c};g.lookup=function(a,
82
- c){return a?this.ns.resolve(a,c):this.ns};g.toString=function(){return"Builder"};l.Message=function(){};l.Enum=function(){};l.Service=function(){};return l}(c,c.Lang,c.Reflect);c.Map=function(a,c){function h(a){var d=0;return{next:function(){return d<a.length?{done:!1,value:a[d++]}:{done:!0}}}}var p=function(a,d){if(!a.map)throw Error("field is not a map");this.field=a;this.keyElem=new c.Element(a.keyType,null,!0,a.syntax);this.valueElem=new c.Element(a.type,a.resolvedType,!1,a.syntax);this.map={};
83
- Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}});if(d)for(var h=Object.keys(d),f=0;f<h.length;f++){var l=this.keyElem.valueFromString(h[f]),p=this.valueElem.verifyValue(d[h[f]]);this.map[this.keyElem.valueToString(l)]={key:l,value:p}}},l=p.prototype;l.clear=function(){this.map={}};l["delete"]=function(a){a=this.keyElem.valueToString(this.keyElem.verifyValue(a));var d=a in this.map;delete this.map[a];return d};l.entries=function(){for(var a=[],d=Object.keys(this.map),
84
- c=0,f;c<d.length;c++)a.push([(f=this.map[d[c]]).key,f.value]);return h(a)};l.keys=function(){for(var a=[],c=Object.keys(this.map),k=0;k<c.length;k++)a.push(this.map[c[k]].key);return h(a)};l.values=function(){for(var a=[],c=Object.keys(this.map),k=0;k<c.length;k++)a.push(this.map[c[k]].value);return h(a)};l.forEach=function(a,c){for(var h=Object.keys(this.map),f=0,l;f<h.length;f++)a.call(c,(l=this.map[h[f]]).value,l.key,this)};l.set=function(a,c){var h=this.keyElem.verifyValue(a),f=this.valueElem.verifyValue(c);
85
- this.map[this.keyElem.valueToString(h)]={key:h,value:f};return this};l.get=function(a){a=this.keyElem.valueToString(this.keyElem.verifyValue(a));return a in this.map?this.map[a].value:void 0};l.has=function(a){return this.keyElem.valueToString(this.keyElem.verifyValue(a))in this.map};return p}(c,c.Reflect);c.newBuilder=function(a){a=a||{};"undefined"===typeof a.convertFieldsToCamelCase&&(a.convertFieldsToCamelCase=c.convertFieldsToCamelCase);"undefined"===typeof a.populateAccessors&&(a.populateAccessors=
86
- c.populateAccessors);return new c.Builder(a)};c.loadJson=function(a,h,s){if("string"===typeof h||h&&"string"===typeof h.file&&"string"===typeof h.root)s=h,h=null;h&&"object"===typeof h||(h=c.newBuilder());"string"===typeof a&&(a=JSON.parse(a));h["import"](a,s);h.resolveAll();return h};c.loadJsonFile=function(a,h,s){h&&"object"===typeof h?(s=h,h=null):h&&"function"===typeof h||(h=null);if(h)return c.Util.fetch("string"===typeof a?a:a.root+"/"+a.file,function(l){if(null===l)h(Error("Failed to fetch file"));
87
- else try{h(null,c.loadJson(JSON.parse(l),s,a))}catch(g){h(g)}});var p=c.Util.fetch("object"===typeof a?a.root+"/"+a.file:a);return null===p?null:c.loadJson(JSON.parse(p),s,a)};return c});
Binary file