protobufjs 6.8.8 → 6.9.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +941 -921
  2. package/LICENSE +39 -39
  3. package/README.md +901 -879
  4. package/cli/LICENSE +33 -33
  5. package/cli/README.md +11 -11
  6. package/cli/index.d.ts +3 -3
  7. package/cli/index.js +3 -3
  8. package/cli/lib/tsd-jsdoc/LICENSE +20 -20
  9. package/cli/lib/tsd-jsdoc/README.md +23 -23
  10. package/cli/lib/tsd-jsdoc/plugin.js +21 -21
  11. package/cli/lib/tsd-jsdoc/publish.js +705 -693
  12. package/cli/lib/tsd-jsdoc.json +18 -18
  13. package/cli/package.json +1 -1
  14. package/cli/package.standalone.json +32 -32
  15. package/cli/pbjs.d.ts +9 -9
  16. package/cli/pbjs.js +329 -329
  17. package/cli/pbts.d.ts +9 -9
  18. package/cli/pbts.js +197 -197
  19. package/cli/targets/json-module.js +38 -38
  20. package/cli/targets/json.js +8 -8
  21. package/cli/targets/proto.js +326 -326
  22. package/cli/targets/proto2.js +10 -10
  23. package/cli/targets/proto3.js +10 -10
  24. package/cli/targets/static-module.js +29 -29
  25. package/cli/targets/static.js +702 -702
  26. package/cli/util.js +183 -183
  27. package/cli/wrappers/amd.js +7 -7
  28. package/cli/wrappers/closure.js +7 -7
  29. package/cli/wrappers/commonjs.js +7 -7
  30. package/cli/wrappers/default.js +15 -15
  31. package/cli/wrappers/es6.js +5 -5
  32. package/dist/README.md +31 -31
  33. package/dist/light/README.md +31 -31
  34. package/dist/light/protobuf.js +6058 -6032
  35. package/dist/light/protobuf.js.map +1 -1
  36. package/dist/light/protobuf.min.js +3 -3
  37. package/dist/light/protobuf.min.js.map +1 -1
  38. package/dist/minimal/README.md +31 -31
  39. package/dist/minimal/protobuf.js +1900 -1877
  40. package/dist/minimal/protobuf.js.map +1 -1
  41. package/dist/minimal/protobuf.min.js +3 -3
  42. package/dist/minimal/protobuf.min.js.map +1 -1
  43. package/dist/protobuf.js +7625 -7596
  44. package/dist/protobuf.js.map +1 -1
  45. package/dist/protobuf.min.js +3 -3
  46. package/dist/protobuf.min.js.map +1 -1
  47. package/ext/debug/README.md +4 -4
  48. package/ext/debug/index.js +71 -71
  49. package/ext/descriptor/README.md +72 -72
  50. package/ext/descriptor/index.js +1052 -1052
  51. package/ext/descriptor/test.js +54 -54
  52. package/google/LICENSE +27 -27
  53. package/google/README.md +1 -1
  54. package/google/api/annotations.proto +10 -10
  55. package/google/protobuf/descriptor.proto +286 -286
  56. package/google/protobuf/source_context.proto +7 -7
  57. package/index.d.ts +6 -6
  58. package/index.js +4 -4
  59. package/light.d.ts +2 -2
  60. package/light.js +3 -3
  61. package/minimal.d.ts +2 -2
  62. package/minimal.js +4 -4
  63. package/package-lock.json +4223 -3171
  64. package/package.json +122 -122
  65. package/scripts/changelog.js +150 -150
  66. package/scripts/postinstall.js +35 -35
  67. package/src/common.js +399 -399
  68. package/src/converter.js +293 -293
  69. package/src/decoder.js +106 -106
  70. package/src/encoder.js +100 -100
  71. package/src/enum.js +181 -181
  72. package/src/field.js +371 -371
  73. package/src/index-light.js +104 -104
  74. package/src/index-minimal.js +36 -36
  75. package/src/index.js +12 -12
  76. package/src/mapfield.js +126 -126
  77. package/src/message.js +138 -138
  78. package/src/method.js +151 -151
  79. package/src/namespace.js +433 -433
  80. package/src/object.js +200 -200
  81. package/src/oneof.js +203 -203
  82. package/src/parse.js +761 -758
  83. package/src/reader.js +411 -405
  84. package/src/reader_buffer.js +51 -44
  85. package/src/root.js +353 -351
  86. package/src/roots.js +18 -18
  87. package/src/rpc/service.js +142 -142
  88. package/src/rpc.js +36 -36
  89. package/src/service.js +167 -167
  90. package/src/tokenize.js +397 -397
  91. package/src/type.js +589 -589
  92. package/src/types.js +196 -196
  93. package/src/typescript.jsdoc +15 -15
  94. package/src/util/longbits.js +200 -200
  95. package/src/util/minimal.js +414 -414
  96. package/src/util.js +178 -178
  97. package/src/verifier.js +176 -176
  98. package/src/wrappers.js +83 -83
  99. package/src/writer.js +465 -459
  100. package/src/writer_buffer.js +85 -81
  101. package/tsconfig.json +6 -6
  102. package/cli/node_modules/os-tmpdir/index.js +0 -25
  103. package/cli/node_modules/os-tmpdir/license +0 -21
  104. package/cli/node_modules/os-tmpdir/readme.md +0 -32
  105. package/cli/node_modules/tmp/LICENSE +0 -21
  106. package/cli/node_modules/tmp/README.md +0 -314
  107. package/cli/node_modules/tmp/lib/tmp.js +0 -611
  108. package/cli/package-lock.json +0 -20
package/src/roots.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- module.exports = {};
3
-
4
- /**
5
- * Named roots.
6
- * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
7
- * Can also be used manually to make roots available accross modules.
8
- * @name roots
9
- * @type {Object.<string,Root>}
10
- * @example
11
- * // pbjs -r myroot -o compiled.js ...
12
- *
13
- * // in another module:
14
- * require("./compiled.js");
15
- *
16
- * // in any subsequent module:
17
- * var root = protobuf.roots["myroot"];
18
- */
1
+ "use strict";
2
+ module.exports = {};
3
+
4
+ /**
5
+ * Named roots.
6
+ * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
7
+ * Can also be used manually to make roots available accross modules.
8
+ * @name roots
9
+ * @type {Object.<string,Root>}
10
+ * @example
11
+ * // pbjs -r myroot -o compiled.js ...
12
+ *
13
+ * // in another module:
14
+ * require("./compiled.js");
15
+ *
16
+ * // in any subsequent module:
17
+ * var root = protobuf.roots["myroot"];
18
+ */
@@ -1,142 +1,142 @@
1
- "use strict";
2
- module.exports = Service;
3
-
4
- var util = require("../util/minimal");
5
-
6
- // Extends EventEmitter
7
- (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
8
-
9
- /**
10
- * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
11
- *
12
- * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.
13
- * @typedef rpc.ServiceMethodCallback
14
- * @template TRes extends Message<TRes>
15
- * @type {function}
16
- * @param {Error|null} error Error, if any
17
- * @param {TRes} [response] Response message
18
- * @returns {undefined}
19
- */
20
-
21
- /**
22
- * A service method part of a {@link rpc.Service} as created by {@link Service.create}.
23
- * @typedef rpc.ServiceMethod
24
- * @template TReq extends Message<TReq>
25
- * @template TRes extends Message<TRes>
26
- * @type {function}
27
- * @param {TReq|Properties<TReq>} request Request message or plain object
28
- * @param {rpc.ServiceMethodCallback<TRes>} [callback] Node-style callback called with the error, if any, and the response message
29
- * @returns {Promise<Message<TRes>>} Promise if `callback` has been omitted, otherwise `undefined`
30
- */
31
-
32
- /**
33
- * Constructs a new RPC service instance.
34
- * @classdesc An RPC service as returned by {@link Service#create}.
35
- * @exports rpc.Service
36
- * @extends util.EventEmitter
37
- * @constructor
38
- * @param {RPCImpl} rpcImpl RPC implementation
39
- * @param {boolean} [requestDelimited=false] Whether requests are length-delimited
40
- * @param {boolean} [responseDelimited=false] Whether responses are length-delimited
41
- */
42
- function Service(rpcImpl, requestDelimited, responseDelimited) {
43
-
44
- if (typeof rpcImpl !== "function")
45
- throw TypeError("rpcImpl must be a function");
46
-
47
- util.EventEmitter.call(this);
48
-
49
- /**
50
- * RPC implementation. Becomes `null` once the service is ended.
51
- * @type {RPCImpl|null}
52
- */
53
- this.rpcImpl = rpcImpl;
54
-
55
- /**
56
- * Whether requests are length-delimited.
57
- * @type {boolean}
58
- */
59
- this.requestDelimited = Boolean(requestDelimited);
60
-
61
- /**
62
- * Whether responses are length-delimited.
63
- * @type {boolean}
64
- */
65
- this.responseDelimited = Boolean(responseDelimited);
66
- }
67
-
68
- /**
69
- * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
70
- * @param {Method|rpc.ServiceMethod<TReq,TRes>} method Reflected or static method
71
- * @param {Constructor<TReq>} requestCtor Request constructor
72
- * @param {Constructor<TRes>} responseCtor Response constructor
73
- * @param {TReq|Properties<TReq>} request Request message or plain object
74
- * @param {rpc.ServiceMethodCallback<TRes>} callback Service callback
75
- * @returns {undefined}
76
- * @template TReq extends Message<TReq>
77
- * @template TRes extends Message<TRes>
78
- */
79
- Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
80
-
81
- if (!request)
82
- throw TypeError("request must be specified");
83
-
84
- var self = this;
85
- if (!callback)
86
- return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
87
-
88
- if (!self.rpcImpl) {
89
- setTimeout(function() { callback(Error("already ended")); }, 0);
90
- return undefined;
91
- }
92
-
93
- try {
94
- return self.rpcImpl(
95
- method,
96
- requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
97
- function rpcCallback(err, response) {
98
-
99
- if (err) {
100
- self.emit("error", err, method);
101
- return callback(err);
102
- }
103
-
104
- if (response === null) {
105
- self.end(/* endedByRPC */ true);
106
- return undefined;
107
- }
108
-
109
- if (!(response instanceof responseCtor)) {
110
- try {
111
- response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response);
112
- } catch (err) {
113
- self.emit("error", err, method);
114
- return callback(err);
115
- }
116
- }
117
-
118
- self.emit("data", response, method);
119
- return callback(null, response);
120
- }
121
- );
122
- } catch (err) {
123
- self.emit("error", err, method);
124
- setTimeout(function() { callback(err); }, 0);
125
- return undefined;
126
- }
127
- };
128
-
129
- /**
130
- * Ends this service and emits the `end` event.
131
- * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.
132
- * @returns {rpc.Service} `this`
133
- */
134
- Service.prototype.end = function end(endedByRPC) {
135
- if (this.rpcImpl) {
136
- if (!endedByRPC) // signal end to rpcImpl
137
- this.rpcImpl(null, null, null);
138
- this.rpcImpl = null;
139
- this.emit("end").off();
140
- }
141
- return this;
142
- };
1
+ "use strict";
2
+ module.exports = Service;
3
+
4
+ var util = require("../util/minimal");
5
+
6
+ // Extends EventEmitter
7
+ (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
8
+
9
+ /**
10
+ * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
11
+ *
12
+ * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.
13
+ * @typedef rpc.ServiceMethodCallback
14
+ * @template TRes extends Message<TRes>
15
+ * @type {function}
16
+ * @param {Error|null} error Error, if any
17
+ * @param {TRes} [response] Response message
18
+ * @returns {undefined}
19
+ */
20
+
21
+ /**
22
+ * A service method part of a {@link rpc.Service} as created by {@link Service.create}.
23
+ * @typedef rpc.ServiceMethod
24
+ * @template TReq extends Message<TReq>
25
+ * @template TRes extends Message<TRes>
26
+ * @type {function}
27
+ * @param {TReq|Properties<TReq>} request Request message or plain object
28
+ * @param {rpc.ServiceMethodCallback<TRes>} [callback] Node-style callback called with the error, if any, and the response message
29
+ * @returns {Promise<Message<TRes>>} Promise if `callback` has been omitted, otherwise `undefined`
30
+ */
31
+
32
+ /**
33
+ * Constructs a new RPC service instance.
34
+ * @classdesc An RPC service as returned by {@link Service#create}.
35
+ * @exports rpc.Service
36
+ * @extends util.EventEmitter
37
+ * @constructor
38
+ * @param {RPCImpl} rpcImpl RPC implementation
39
+ * @param {boolean} [requestDelimited=false] Whether requests are length-delimited
40
+ * @param {boolean} [responseDelimited=false] Whether responses are length-delimited
41
+ */
42
+ function Service(rpcImpl, requestDelimited, responseDelimited) {
43
+
44
+ if (typeof rpcImpl !== "function")
45
+ throw TypeError("rpcImpl must be a function");
46
+
47
+ util.EventEmitter.call(this);
48
+
49
+ /**
50
+ * RPC implementation. Becomes `null` once the service is ended.
51
+ * @type {RPCImpl|null}
52
+ */
53
+ this.rpcImpl = rpcImpl;
54
+
55
+ /**
56
+ * Whether requests are length-delimited.
57
+ * @type {boolean}
58
+ */
59
+ this.requestDelimited = Boolean(requestDelimited);
60
+
61
+ /**
62
+ * Whether responses are length-delimited.
63
+ * @type {boolean}
64
+ */
65
+ this.responseDelimited = Boolean(responseDelimited);
66
+ }
67
+
68
+ /**
69
+ * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
70
+ * @param {Method|rpc.ServiceMethod<TReq,TRes>} method Reflected or static method
71
+ * @param {Constructor<TReq>} requestCtor Request constructor
72
+ * @param {Constructor<TRes>} responseCtor Response constructor
73
+ * @param {TReq|Properties<TReq>} request Request message or plain object
74
+ * @param {rpc.ServiceMethodCallback<TRes>} callback Service callback
75
+ * @returns {undefined}
76
+ * @template TReq extends Message<TReq>
77
+ * @template TRes extends Message<TRes>
78
+ */
79
+ Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
80
+
81
+ if (!request)
82
+ throw TypeError("request must be specified");
83
+
84
+ var self = this;
85
+ if (!callback)
86
+ return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);
87
+
88
+ if (!self.rpcImpl) {
89
+ setTimeout(function() { callback(Error("already ended")); }, 0);
90
+ return undefined;
91
+ }
92
+
93
+ try {
94
+ return self.rpcImpl(
95
+ method,
96
+ requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
97
+ function rpcCallback(err, response) {
98
+
99
+ if (err) {
100
+ self.emit("error", err, method);
101
+ return callback(err);
102
+ }
103
+
104
+ if (response === null) {
105
+ self.end(/* endedByRPC */ true);
106
+ return undefined;
107
+ }
108
+
109
+ if (!(response instanceof responseCtor)) {
110
+ try {
111
+ response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response);
112
+ } catch (err) {
113
+ self.emit("error", err, method);
114
+ return callback(err);
115
+ }
116
+ }
117
+
118
+ self.emit("data", response, method);
119
+ return callback(null, response);
120
+ }
121
+ );
122
+ } catch (err) {
123
+ self.emit("error", err, method);
124
+ setTimeout(function() { callback(err); }, 0);
125
+ return undefined;
126
+ }
127
+ };
128
+
129
+ /**
130
+ * Ends this service and emits the `end` event.
131
+ * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.
132
+ * @returns {rpc.Service} `this`
133
+ */
134
+ Service.prototype.end = function end(endedByRPC) {
135
+ if (this.rpcImpl) {
136
+ if (!endedByRPC) // signal end to rpcImpl
137
+ this.rpcImpl(null, null, null);
138
+ this.rpcImpl = null;
139
+ this.emit("end").off();
140
+ }
141
+ return this;
142
+ };
package/src/rpc.js CHANGED
@@ -1,36 +1,36 @@
1
- "use strict";
2
-
3
- /**
4
- * Streaming RPC helpers.
5
- * @namespace
6
- */
7
- var rpc = exports;
8
-
9
- /**
10
- * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
11
- * @typedef RPCImpl
12
- * @type {function}
13
- * @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called
14
- * @param {Uint8Array} requestData Request data
15
- * @param {RPCImplCallback} callback Callback function
16
- * @returns {undefined}
17
- * @example
18
- * function rpcImpl(method, requestData, callback) {
19
- * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
20
- * throw Error("no such method");
21
- * asynchronouslyObtainAResponse(requestData, function(err, responseData) {
22
- * callback(err, responseData);
23
- * });
24
- * }
25
- */
26
-
27
- /**
28
- * Node-style callback as used by {@link RPCImpl}.
29
- * @typedef RPCImplCallback
30
- * @type {function}
31
- * @param {Error|null} error Error, if any, otherwise `null`
32
- * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
33
- * @returns {undefined}
34
- */
35
-
36
- rpc.Service = require("./rpc/service");
1
+ "use strict";
2
+
3
+ /**
4
+ * Streaming RPC helpers.
5
+ * @namespace
6
+ */
7
+ var rpc = exports;
8
+
9
+ /**
10
+ * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
11
+ * @typedef RPCImpl
12
+ * @type {function}
13
+ * @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called
14
+ * @param {Uint8Array} requestData Request data
15
+ * @param {RPCImplCallback} callback Callback function
16
+ * @returns {undefined}
17
+ * @example
18
+ * function rpcImpl(method, requestData, callback) {
19
+ * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
20
+ * throw Error("no such method");
21
+ * asynchronouslyObtainAResponse(requestData, function(err, responseData) {
22
+ * callback(err, responseData);
23
+ * });
24
+ * }
25
+ */
26
+
27
+ /**
28
+ * Node-style callback as used by {@link RPCImpl}.
29
+ * @typedef RPCImplCallback
30
+ * @type {function}
31
+ * @param {Error|null} error Error, if any, otherwise `null`
32
+ * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
33
+ * @returns {undefined}
34
+ */
35
+
36
+ rpc.Service = require("./rpc/service");