tardis-machine 18.0.0 → 18.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 (208) hide show
  1. package/benchmark.js +35 -14
  2. package/bin/tardis-machine.js +0 -1
  3. package/dist/tardismachine.d.ts.map +1 -1
  4. package/dist/tardismachine.js +20 -55
  5. package/dist/tardismachine.js.map +1 -1
  6. package/dist/ws/replay.d.ts +2 -2
  7. package/dist/ws/replay.d.ts.map +1 -1
  8. package/dist/ws/replay.js +11 -5
  9. package/dist/ws/replay.js.map +1 -1
  10. package/dist/ws/replaynormalized.d.ts +2 -2
  11. package/dist/ws/replaynormalized.d.ts.map +1 -1
  12. package/dist/ws/replaynormalized.js +7 -5
  13. package/dist/ws/replaynormalized.js.map +1 -1
  14. package/dist/ws/server.d.ts +20 -0
  15. package/dist/ws/server.d.ts.map +1 -0
  16. package/dist/ws/server.js +154 -0
  17. package/dist/ws/server.js.map +1 -0
  18. package/dist/ws/streamnormalized.d.ts +2 -2
  19. package/dist/ws/streamnormalized.d.ts.map +1 -1
  20. package/dist/ws/streamnormalized.js +7 -5
  21. package/dist/ws/streamnormalized.js.map +1 -1
  22. package/dist/ws/subscriptionsmappers.d.ts +1 -1
  23. package/dist/ws/subscriptionsmappers.d.ts.map +1 -1
  24. package/node_modules/tardis-dev/README.md +1 -1
  25. package/node_modules/tardis-dev/dist/debug.d.ts +12 -2
  26. package/node_modules/tardis-dev/dist/debug.d.ts.map +1 -1
  27. package/node_modules/tardis-dev/dist/debug.js +2 -1
  28. package/node_modules/tardis-dev/dist/debug.js.map +1 -1
  29. package/node_modules/tardis-dev/dist/handy.d.ts +3 -1
  30. package/node_modules/tardis-dev/dist/handy.d.ts.map +1 -1
  31. package/node_modules/tardis-dev/dist/handy.js +72 -86
  32. package/node_modules/tardis-dev/dist/handy.js.map +1 -1
  33. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts +0 -7
  34. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts.map +1 -1
  35. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js +2 -70
  36. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js.map +1 -1
  37. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts +43 -0
  38. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts.map +1 -0
  39. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js +294 -0
  40. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js.map +1 -0
  41. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts +3 -3
  42. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
  43. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js +3 -3
  44. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js.map +1 -1
  45. package/node_modules/tardis-dev/dist/worker.js +2 -2
  46. package/node_modules/tardis-dev/dist/worker.js.map +1 -1
  47. package/node_modules/tardis-dev/package.json +3 -7
  48. package/node_modules/tardis-dev/src/debug.ts +16 -1
  49. package/node_modules/tardis-dev/src/external-modules.d.ts +5 -0
  50. package/node_modules/tardis-dev/src/handy.ts +93 -89
  51. package/node_modules/tardis-dev/src/realtimefeeds/mexc.ts +2 -72
  52. package/node_modules/tardis-dev/src/realtimefeeds/mexcprotobuf.ts +364 -0
  53. package/node_modules/tardis-dev/src/realtimefeeds/realtimefeed.ts +5 -5
  54. package/node_modules/tardis-dev/src/worker.ts +2 -2
  55. package/package.json +8 -34
  56. package/src/tardismachine.ts +25 -66
  57. package/src/ws/replay.ts +13 -8
  58. package/src/ws/replaynormalized.ts +8 -6
  59. package/src/ws/server.ts +173 -0
  60. package/src/ws/streamnormalized.ts +8 -6
  61. package/src/ws/subscriptionsmappers.ts +1 -1
  62. package/node_modules/follow-redirects/LICENSE +0 -18
  63. package/node_modules/follow-redirects/README.md +0 -157
  64. package/node_modules/follow-redirects/debug.js +0 -15
  65. package/node_modules/follow-redirects/http.js +0 -1
  66. package/node_modules/follow-redirects/https.js +0 -1
  67. package/node_modules/follow-redirects/index.js +0 -709
  68. package/node_modules/follow-redirects/package.json +0 -58
  69. package/node_modules/long/LICENSE +0 -202
  70. package/node_modules/long/README.md +0 -286
  71. package/node_modules/long/index.d.ts +0 -2
  72. package/node_modules/long/index.js +0 -1581
  73. package/node_modules/long/package.json +0 -58
  74. package/node_modules/long/types.d.ts +0 -474
  75. package/node_modules/long/umd/index.d.ts +0 -3
  76. package/node_modules/long/umd/index.js +0 -1622
  77. package/node_modules/long/umd/package.json +0 -3
  78. package/node_modules/long/umd/types.d.ts +0 -474
  79. package/node_modules/protobufjs/LICENSE +0 -39
  80. package/node_modules/protobufjs/README.md +0 -440
  81. package/node_modules/protobufjs/dist/light/protobuf.js +0 -9276
  82. package/node_modules/protobufjs/dist/light/protobuf.js.map +0 -1
  83. package/node_modules/protobufjs/dist/light/protobuf.min.js +0 -8
  84. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +0 -1
  85. package/node_modules/protobufjs/dist/minimal/protobuf.js +0 -3556
  86. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +0 -1
  87. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +0 -8
  88. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +0 -1
  89. package/node_modules/protobufjs/dist/protobuf.js +0 -11233
  90. package/node_modules/protobufjs/dist/protobuf.js.map +0 -1
  91. package/node_modules/protobufjs/dist/protobuf.min.js +0 -8
  92. package/node_modules/protobufjs/dist/protobuf.min.js.map +0 -1
  93. package/node_modules/protobufjs/ext/README.md +0 -70
  94. package/node_modules/protobufjs/ext/debug/README.md +0 -4
  95. package/node_modules/protobufjs/ext/debug/index.js +0 -71
  96. package/node_modules/protobufjs/ext/descriptor/README.md +0 -5
  97. package/node_modules/protobufjs/ext/descriptor/index.d.ts +0 -2
  98. package/node_modules/protobufjs/ext/descriptor/index.js +0 -2
  99. package/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
  100. package/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -417
  101. package/node_modules/protobufjs/ext/descriptor.js +0 -1356
  102. package/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
  103. package/node_modules/protobufjs/ext/protojson.d.ts +0 -20
  104. package/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
  105. package/node_modules/protobufjs/ext/protojson.js +0 -951
  106. package/node_modules/protobufjs/ext/textformat.d.ts +0 -19
  107. package/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
  108. package/node_modules/protobufjs/ext/textformat.js +0 -1276
  109. package/node_modules/protobufjs/google/LICENSE +0 -27
  110. package/node_modules/protobufjs/google/README.md +0 -1
  111. package/node_modules/protobufjs/google/api/annotations.json +0 -85
  112. package/node_modules/protobufjs/google/api/annotations.proto +0 -11
  113. package/node_modules/protobufjs/google/api/http.json +0 -87
  114. package/node_modules/protobufjs/google/api/http.proto +0 -31
  115. package/node_modules/protobufjs/google/protobuf/api.json +0 -124
  116. package/node_modules/protobufjs/google/protobuf/api.proto +0 -34
  117. package/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
  118. package/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
  119. package/node_modules/protobufjs/google/protobuf/descriptor.json +0 -1465
  120. package/node_modules/protobufjs/google/protobuf/descriptor.proto +0 -527
  121. package/node_modules/protobufjs/google/protobuf/source_context.json +0 -21
  122. package/node_modules/protobufjs/google/protobuf/source_context.proto +0 -7
  123. package/node_modules/protobufjs/google/protobuf/type.json +0 -209
  124. package/node_modules/protobufjs/google/protobuf/type.proto +0 -89
  125. package/node_modules/protobufjs/index.d.ts +0 -3203
  126. package/node_modules/protobufjs/index.js +0 -4
  127. package/node_modules/protobufjs/light.d.ts +0 -2
  128. package/node_modules/protobufjs/light.js +0 -4
  129. package/node_modules/protobufjs/minimal.d.ts +0 -2
  130. package/node_modules/protobufjs/minimal.js +0 -4
  131. package/node_modules/protobufjs/package.json +0 -93
  132. package/node_modules/protobufjs/src/common.js +0 -405
  133. package/node_modules/protobufjs/src/converter.js +0 -352
  134. package/node_modules/protobufjs/src/decoder.js +0 -279
  135. package/node_modules/protobufjs/src/encoder.js +0 -123
  136. package/node_modules/protobufjs/src/enum.js +0 -239
  137. package/node_modules/protobufjs/src/field.js +0 -505
  138. package/node_modules/protobufjs/src/index-light.js +0 -104
  139. package/node_modules/protobufjs/src/index-minimal.js +0 -35
  140. package/node_modules/protobufjs/src/index.js +0 -12
  141. package/node_modules/protobufjs/src/mapfield.js +0 -144
  142. package/node_modules/protobufjs/src/message.js +0 -137
  143. package/node_modules/protobufjs/src/method.js +0 -183
  144. package/node_modules/protobufjs/src/namespace.js +0 -574
  145. package/node_modules/protobufjs/src/object.js +0 -392
  146. package/node_modules/protobufjs/src/oneof.js +0 -233
  147. package/node_modules/protobufjs/src/parse.js +0 -1111
  148. package/node_modules/protobufjs/src/reader.js +0 -788
  149. package/node_modules/protobufjs/src/reader_buffer.js +0 -77
  150. package/node_modules/protobufjs/src/root.js +0 -424
  151. package/node_modules/protobufjs/src/roots.js +0 -18
  152. package/node_modules/protobufjs/src/rpc/service.js +0 -155
  153. package/node_modules/protobufjs/src/rpc.js +0 -36
  154. package/node_modules/protobufjs/src/service.js +0 -206
  155. package/node_modules/protobufjs/src/tokenize.js +0 -421
  156. package/node_modules/protobufjs/src/type.js +0 -676
  157. package/node_modules/protobufjs/src/types.js +0 -196
  158. package/node_modules/protobufjs/src/typescript.js +0 -25
  159. package/node_modules/protobufjs/src/util/aspromise.d.ts +0 -13
  160. package/node_modules/protobufjs/src/util/aspromise.js +0 -52
  161. package/node_modules/protobufjs/src/util/base64.d.ts +0 -32
  162. package/node_modules/protobufjs/src/util/base64.js +0 -146
  163. package/node_modules/protobufjs/src/util/codegen.d.ts +0 -31
  164. package/node_modules/protobufjs/src/util/codegen.js +0 -118
  165. package/node_modules/protobufjs/src/util/eventemitter.d.ts +0 -45
  166. package/node_modules/protobufjs/src/util/eventemitter.js +0 -86
  167. package/node_modules/protobufjs/src/util/fetch.d.ts +0 -56
  168. package/node_modules/protobufjs/src/util/fetch.js +0 -112
  169. package/node_modules/protobufjs/src/util/float.d.ts +0 -83
  170. package/node_modules/protobufjs/src/util/float.js +0 -335
  171. package/node_modules/protobufjs/src/util/fs.js +0 -11
  172. package/node_modules/protobufjs/src/util/longbits.js +0 -204
  173. package/node_modules/protobufjs/src/util/minimal.js +0 -511
  174. package/node_modules/protobufjs/src/util/path.d.ts +0 -22
  175. package/node_modules/protobufjs/src/util/path.js +0 -100
  176. package/node_modules/protobufjs/src/util/patterns.js +0 -7
  177. package/node_modules/protobufjs/src/util/pool.d.ts +0 -32
  178. package/node_modules/protobufjs/src/util/pool.js +0 -48
  179. package/node_modules/protobufjs/src/util/utf8.d.ts +0 -24
  180. package/node_modules/protobufjs/src/util/utf8.js +0 -190
  181. package/node_modules/protobufjs/src/util.js +0 -264
  182. package/node_modules/protobufjs/src/verifier.js +0 -185
  183. package/node_modules/protobufjs/src/wrappers.js +0 -106
  184. package/node_modules/protobufjs/src/writer.js +0 -700
  185. package/node_modules/protobufjs/src/writer_buffer.js +0 -100
  186. package/node_modules/protobufjs/tsconfig.json +0 -6
  187. package/node_modules/uWebSockets.js/ESM_wrapper.mjs +0 -53
  188. package/node_modules/uWebSockets.js/LICENSE +0 -201
  189. package/node_modules/uWebSockets.js/README.md +0 -6
  190. package/node_modules/uWebSockets.js/index.d.ts +0 -468
  191. package/node_modules/uWebSockets.js/package.json +0 -12
  192. package/node_modules/uWebSockets.js/source_commit +0 -1
  193. package/node_modules/uWebSockets.js/uws.js +0 -76
  194. package/node_modules/uWebSockets.js/uws_darwin_arm64_127.node +0 -0
  195. package/node_modules/uWebSockets.js/uws_darwin_arm64_137.node +0 -0
  196. package/node_modules/uWebSockets.js/uws_darwin_arm64_147.node +0 -0
  197. package/node_modules/uWebSockets.js/uws_darwin_x64_127.node +0 -0
  198. package/node_modules/uWebSockets.js/uws_darwin_x64_137.node +0 -0
  199. package/node_modules/uWebSockets.js/uws_darwin_x64_147.node +0 -0
  200. package/node_modules/uWebSockets.js/uws_linux_arm64_127.node +0 -0
  201. package/node_modules/uWebSockets.js/uws_linux_arm64_137.node +0 -0
  202. package/node_modules/uWebSockets.js/uws_linux_arm64_147.node +0 -0
  203. package/node_modules/uWebSockets.js/uws_linux_x64_127.node +0 -0
  204. package/node_modules/uWebSockets.js/uws_linux_x64_137.node +0 -0
  205. package/node_modules/uWebSockets.js/uws_linux_x64_147.node +0 -0
  206. package/node_modules/uWebSockets.js/uws_win32_x64_127.node +0 -0
  207. package/node_modules/uWebSockets.js/uws_win32_x64_137.node +0 -0
  208. package/node_modules/uWebSockets.js/uws_win32_x64_147.node +0 -0
@@ -1,505 +0,0 @@
1
- "use strict";
2
- module.exports = Field;
3
-
4
- // extends ReflectionObject
5
- var ReflectionObject = require("./object");
6
- Field.prototype = Object.create(ReflectionObject.prototype, {
7
- constructor: {
8
- value: Field,
9
- writable: true,
10
- enumerable: false,
11
- configurable: true
12
- }
13
- });
14
- Field.className = "Field";
15
-
16
- var Enum = require("./enum"),
17
- types = require("./types"),
18
- util = require("./util");
19
-
20
- var Type; // cyclic
21
-
22
- var ruleRe = /^(?:required|optional|repeated)$/;
23
-
24
- /**
25
- * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.
26
- * @name Field
27
- * @classdesc Reflected message field.
28
- * @extends FieldBase
29
- * @constructor
30
- * @param {string} name Unique name within its namespace
31
- * @param {number} id Unique id within its namespace
32
- * @param {string} type Value type
33
- * @param {string|Object.<string,*>} [rule="optional"] Field rule
34
- * @param {string|Object.<string,*>} [extend] Extended type if different from parent
35
- * @param {Object.<string,*>} [options] Declared options
36
- */
37
-
38
- /**
39
- * Constructs a field from a field descriptor.
40
- * @param {string} name Field name
41
- * @param {IField} json Field descriptor
42
- * @returns {Field} Created field
43
- * @throws {TypeError} If arguments are invalid
44
- */
45
- Field.fromJSON = function fromJSON(name, json) {
46
- var field = new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);
47
- if (json.edition)
48
- field._edition = json.edition;
49
- if (json.protoName)
50
- field.protoName = json.protoName;
51
- if (json.jsonName !== undefined)
52
- field.jsonName = json.jsonName;
53
- else if (json.options && json.options.json_name !== undefined)
54
- field.jsonName = json.options.json_name;
55
- field._defaultEdition = "proto3"; // For backwards-compatibility.
56
- return field;
57
- };
58
-
59
- /**
60
- * Not an actual constructor. Use {@link Field} instead.
61
- * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions.
62
- * @exports FieldBase
63
- * @extends ReflectionObject
64
- * @constructor
65
- * @param {string} name Unique name within its namespace
66
- * @param {number} id Unique id within its namespace
67
- * @param {string} type Value type
68
- * @param {string|Object.<string,*>} [rule="optional"] Field rule
69
- * @param {string|Object.<string,*>} [extend] Extended type if different from parent
70
- * @param {Object.<string,*>} [options] Declared options
71
- * @param {string} [comment] Comment associated with this field
72
- */
73
- function Field(name, id, type, rule, extend, options, comment) {
74
-
75
- if (util.isObject(rule)) {
76
- comment = extend;
77
- options = rule;
78
- rule = extend = undefined;
79
- } else if (util.isObject(extend)) {
80
- comment = options;
81
- options = extend;
82
- extend = undefined;
83
- }
84
-
85
- ReflectionObject.call(this, name, options);
86
-
87
- if (!util.isInteger(id) || id < 0)
88
- throw TypeError("id must be a non-negative integer");
89
-
90
- if (!util.isString(type))
91
- throw TypeError("type must be a string");
92
-
93
- if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase()))
94
- throw TypeError("rule must be a string rule");
95
-
96
- if (extend !== undefined && !util.isString(extend))
97
- throw TypeError("extend must be a string");
98
-
99
- /**
100
- * Field rule, if any.
101
- * @type {string|undefined}
102
- */
103
- this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON
104
-
105
- /**
106
- * Field type.
107
- * @type {string}
108
- */
109
- this.type = type; // toJSON
110
-
111
- /**
112
- * Unique field id.
113
- * @type {number}
114
- */
115
- this.id = id; // toJSON, marker
116
-
117
- /**
118
- * Extended type if different from parent.
119
- * @type {string|undefined}
120
- */
121
- this.extend = extend || undefined; // toJSON
122
-
123
- /**
124
- * Whether this field is repeated.
125
- * @type {boolean}
126
- */
127
- this.repeated = rule === "repeated";
128
-
129
- /**
130
- * Whether this field is a map or not.
131
- * @type {boolean}
132
- */
133
- this.map = false;
134
-
135
- /**
136
- * Message this field belongs to.
137
- * @type {Type|null}
138
- */
139
- this.message = null;
140
-
141
- /**
142
- * OneOf this field belongs to, if any,
143
- * @type {OneOf|null}
144
- */
145
- this.partOf = null;
146
-
147
- /**
148
- * The field type's default value.
149
- * @type {*}
150
- */
151
- this.typeDefault = null;
152
-
153
- /**
154
- * The field's default value on prototypes.
155
- * @type {*}
156
- */
157
- this.defaultValue = null;
158
-
159
- /**
160
- * Whether this field's value should be treated as a long.
161
- * @type {boolean}
162
- */
163
- this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false;
164
-
165
- /**
166
- * Whether this field's value is a buffer.
167
- * @type {boolean}
168
- */
169
- this.bytes = type === "bytes";
170
-
171
- /**
172
- * Resolved type if not a basic type.
173
- * @type {Type|Enum|null}
174
- */
175
- this.resolvedType = null;
176
-
177
- /**
178
- * Sister-field within the extended type if a declaring extension field.
179
- * @type {Field|null}
180
- */
181
- this.extensionField = null;
182
-
183
- /**
184
- * Sister-field within the declaring namespace if an extended field.
185
- * @type {Field|null}
186
- */
187
- this.declaringField = null;
188
-
189
- /**
190
- * Comment for this field.
191
- * @type {string|null}
192
- */
193
- this.comment = comment;
194
-
195
- /**
196
- * Field name as declared in the .proto source, if different from `name`.
197
- * @type {string|undefined}
198
- */
199
- this.protoName = undefined;
200
-
201
- /**
202
- * JSON name, if different from the derived default.
203
- * @type {string|undefined}
204
- */
205
- this.jsonName = undefined;
206
- }
207
-
208
- /**
209
- * Determines whether this field is required.
210
- * @name Field#required
211
- * @type {boolean}
212
- * @readonly
213
- */
214
- Object.defineProperty(Field.prototype, "required", {
215
- get: function() {
216
- return this._features.field_presence === "LEGACY_REQUIRED";
217
- }
218
- });
219
-
220
- /**
221
- * Determines whether this field is not required.
222
- * @name Field#optional
223
- * @type {boolean}
224
- * @readonly
225
- */
226
- Object.defineProperty(Field.prototype, "optional", {
227
- get: function() {
228
- return !this.required;
229
- }
230
- });
231
-
232
- /**
233
- * Determines whether this field uses tag-delimited encoding. In proto2 this
234
- * corresponded to group syntax.
235
- * @name Field#delimited
236
- * @type {boolean}
237
- * @readonly
238
- */
239
- Object.defineProperty(Field.prototype, "delimited", {
240
- get: function() {
241
- return this.resolvedType instanceof Type &&
242
- this._features.message_encoding === "DELIMITED";
243
- }
244
- });
245
-
246
- /**
247
- * Determines whether this field is packed. Only relevant when repeated.
248
- * @name Field#packed
249
- * @type {boolean}
250
- * @readonly
251
- */
252
- Object.defineProperty(Field.prototype, "packed", {
253
- get: function() {
254
- return this._features.repeated_field_encoding === "PACKED";
255
- }
256
- });
257
-
258
- /**
259
- * Determines whether this field tracks presence.
260
- * @name Field#hasPresence
261
- * @type {boolean}
262
- * @readonly
263
- */
264
- Object.defineProperty(Field.prototype, "hasPresence", {
265
- get: function() {
266
- if (this.repeated || this.map) {
267
- return false;
268
- }
269
- return this.partOf || // oneofs
270
- this.declaringField || this.extensionField || // extensions
271
- this._features.field_presence !== "IMPLICIT";
272
- }
273
- });
274
-
275
- /**
276
- * The field name as declared in the .proto source (snake_case). Populated on resolve,
277
- * falling back to `name`. Mirrors `FieldDescriptorProto.name`.
278
- * @name Field#protoName
279
- * @type {string}
280
- * @readonly
281
- */
282
-
283
- /**
284
- * The JSON name of this field (lowerCamelCase per protoc's `ToJsonName`, or an
285
- * explicit `[json_name]`). Populated on resolve. This is the key used on ProtoJSON output.
286
- * @name Field#jsonName
287
- * @type {string}
288
- * @readonly
289
- */
290
-
291
- /**
292
- * @override
293
- */
294
- Field.prototype.setOption = function setOption(name, value, ifNotSet) {
295
- return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet);
296
- };
297
-
298
- /**
299
- * Field descriptor.
300
- * @interface IField
301
- * @property {string} [edition] Edition
302
- * @property {string} [rule="optional"] Field rule
303
- * @property {string} type Field type
304
- * @property {number} id Field id
305
- * @property {Object.<string,*>} [options] Field options
306
- * @property {string|null} [comment] Field comment
307
- */
308
-
309
- /**
310
- * Extension field descriptor.
311
- * @interface IExtensionField
312
- * @extends IField
313
- * @property {string} extend Extended type
314
- */
315
-
316
- /**
317
- * Converts this field to a field descriptor.
318
- * @param {IToJSONOptions} [toJSONOptions] JSON conversion options
319
- * @returns {IField} Field descriptor
320
- */
321
- Field.prototype.toJSON = function toJSON(toJSONOptions) {
322
- var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
323
- return util.toObject([
324
- "edition" , this._editionToJSON(),
325
- "rule" , this.rule !== "optional" && this.rule || undefined,
326
- "type" , this.type,
327
- "id" , this.id,
328
- "extend" , this.extend,
329
- "protoName" , this.protoName !== this.name ? this.protoName : undefined,
330
- "jsonName" , this.jsonName !== util.jsonName(this.protoName || this.name) ? this.jsonName : undefined,
331
- "options" , this.options,
332
- "comment" , keepComments ? this.comment : undefined
333
- ]);
334
- };
335
-
336
- /**
337
- * Resolves this field's type references.
338
- * @returns {Field} `this`
339
- * @throws {Error} If any reference cannot be resolved
340
- */
341
- Field.prototype.resolve = function resolve() {
342
-
343
- if (this.resolved)
344
- return this;
345
-
346
- if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it
347
- this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type);
348
- if (this.resolvedType instanceof Type)
349
- this.typeDefault = null;
350
- else // instanceof Enum
351
- this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined
352
- } else if (this.options && this.options.proto3_optional) {
353
- // proto3 scalar value marked optional; should default to null
354
- this.typeDefault = null;
355
- }
356
-
357
- // use explicitly set default value if present
358
- if (this.options && this.options["default"] != null) {
359
- this.typeDefault = this.options["default"];
360
- if (this.resolvedType instanceof Enum && typeof this.typeDefault === "string")
361
- this.typeDefault = this.resolvedType.values[this.typeDefault];
362
- }
363
-
364
- // remove unnecessary options
365
- if (this.options) {
366
- if (this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum))
367
- delete this.options.packed;
368
- if (!Object.keys(this.options).length)
369
- this.options = undefined;
370
- }
371
-
372
- // convert to internal data type if necesssary
373
- if (this.long) {
374
- this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
375
-
376
- /* istanbul ignore else */
377
- if (Object.freeze)
378
- Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)
379
-
380
- } else if (this.bytes && typeof this.typeDefault === "string") {
381
- var buf;
382
- if (util.base64.test(this.typeDefault))
383
- util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0);
384
- else
385
- util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0);
386
- this.typeDefault = buf;
387
- }
388
-
389
- // take special care of maps and repeated fields
390
- if (this.map)
391
- this.defaultValue = util.emptyObject;
392
- else if (this.repeated)
393
- this.defaultValue = util.emptyArray;
394
- else
395
- this.defaultValue = this.typeDefault;
396
-
397
- // ensure proper value on prototype
398
- if (this.parent instanceof Type && this.parent._ctor)
399
- this.parent._ctor.prototype[this.name] = this.defaultValue;
400
-
401
- // derive the proto/JSON names
402
- if (this.protoName === undefined)
403
- this.protoName = this.name;
404
- if (this.jsonName === undefined)
405
- this.jsonName = util.jsonName(this.protoName);
406
-
407
- return ReflectionObject.prototype.resolve.call(this);
408
- };
409
-
410
- /**
411
- * Infers field features from legacy syntax that may have been specified differently.
412
- * in older editions.
413
- * @param {string|undefined} edition The edition this proto is on, or undefined if pre-editions
414
- * @returns {object} The feature values to override
415
- */
416
- Field.prototype._inferLegacyProtoFeatures = function _inferLegacyProtoFeatures(edition) {
417
- if (edition !== "proto2" && edition !== "proto3") {
418
- return {};
419
- }
420
-
421
- var features = {};
422
-
423
- if (this.rule === "required") {
424
- features.field_presence = "LEGACY_REQUIRED";
425
- }
426
- if (this.parent && types.defaults[this.type] === undefined) {
427
- // We can't use resolvedType because types may not have been resolved yet. However,
428
- // legacy groups are always in the same scope as the field so we don't have to do a
429
- // full scan of the tree.
430
- var type = this.parent.get(this.type.split(".").pop());
431
- if (type && type instanceof Type && type.group) {
432
- features.message_encoding = "DELIMITED";
433
- }
434
- }
435
- if (this.getOption("packed") === true) {
436
- features.repeated_field_encoding = "PACKED";
437
- } else if (this.getOption("packed") === false) {
438
- features.repeated_field_encoding = "EXPANDED";
439
- }
440
- return features;
441
- };
442
-
443
- /**
444
- * @override
445
- */
446
- Field.prototype._resolveFeatures = function _resolveFeatures(edition) {
447
- return ReflectionObject.prototype._resolveFeatures.call(this, this._edition || edition);
448
- };
449
-
450
- /**
451
- * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).
452
- * @typedef FieldDecorator
453
- * @type {function}
454
- * @param {Object} prototype Target prototype
455
- * @param {string} fieldName Field name
456
- * @returns {undefined}
457
- * @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
458
- */
459
-
460
- /**
461
- * Field decorator (TypeScript).
462
- * @name Field.d
463
- * @function
464
- * @param {number} fieldId Field id
465
- * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|Object} fieldType Field type
466
- * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule
467
- * @param {T} [defaultValue] Default value
468
- * @returns {FieldDecorator} Decorator function
469
- * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]
470
- * @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
471
- */
472
- Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {
473
-
474
- // submessage: decorate the submessage and use its name as the type
475
- if (typeof fieldType === "function")
476
- fieldType = util.decorateType(fieldType).name;
477
-
478
- // enum reference: create a reflected copy of the enum and keep reuseing it
479
- else if (fieldType && typeof fieldType === "object")
480
- fieldType = util.decorateEnum(fieldType).name;
481
-
482
- return function fieldDecorator(prototype, fieldName) {
483
- util.decorateType(prototype.constructor)
484
- .add(new Field(fieldName, fieldId, fieldType, fieldRule, { "default": defaultValue }));
485
- };
486
- };
487
-
488
- // Sets up cyclic dependencies (called in index-light)
489
- Field._configure = function configure(Type_) {
490
- Type = Type_;
491
- };
492
-
493
- /**
494
- * Field decorator (TypeScript).
495
- * @name Field.d
496
- * @function
497
- * @param {number} fieldId Field id
498
- * @param {Constructor<T>|string} fieldType Field type
499
- * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule
500
- * @returns {FieldDecorator} Decorator function
501
- * @template T extends Message<T>
502
- * @variation 2
503
- * @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
504
- */
505
- // like Field.d but without a default value
@@ -1,104 +0,0 @@
1
- "use strict";
2
- exports = module.exports = require("./index-minimal");
3
-
4
- exports.build = "light";
5
-
6
- /**
7
- * A node-style callback as used by {@link load} and {@link Root#load}.
8
- * @typedef LoadCallback
9
- * @type {function}
10
- * @param {Error|null} error Error, if any, otherwise `null`
11
- * @param {Root} [root] Root, if there hasn't been an error
12
- * @returns {undefined}
13
- */
14
-
15
- /**
16
- * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
17
- * @param {string|string[]} filename One or multiple files to load
18
- * @param {Root} root Root namespace, defaults to create a new one if omitted.
19
- * @param {LoadCallback} callback Callback function
20
- * @returns {undefined}
21
- * @see {@link Root#load}
22
- */
23
- function load(filename, root, callback) {
24
- if (typeof root === "function") {
25
- callback = root;
26
- root = new exports.Root();
27
- } else if (!root)
28
- root = new exports.Root();
29
- return root.load(filename, callback);
30
- }
31
-
32
- /**
33
- * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
34
- * @name load
35
- * @function
36
- * @param {string|string[]} filename One or multiple files to load
37
- * @param {LoadCallback} callback Callback function
38
- * @returns {undefined}
39
- * @see {@link Root#load}
40
- * @variation 2
41
- */
42
- // function load(filename:string, callback:LoadCallback):undefined
43
-
44
- /**
45
- * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.
46
- * @name load
47
- * @function
48
- * @param {string|string[]} filename One or multiple files to load
49
- * @param {Root} [root] Root namespace, defaults to create a new one if omitted.
50
- * @returns {Promise<Root>} Promise
51
- * @see {@link Root#load}
52
- * @variation 3
53
- */
54
- // function load(filename:string, [root:Root]):Promise<Root>
55
-
56
- exports.load = load;
57
-
58
- /**
59
- * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).
60
- * @param {string|string[]} filename One or multiple files to load
61
- * @param {Root} [root] Root namespace, defaults to create a new one if omitted.
62
- * @returns {Root} Root namespace
63
- * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid
64
- * @see {@link Root#loadSync}
65
- */
66
- function loadSync(filename, root) {
67
- if (!root)
68
- root = new exports.Root();
69
- return root.loadSync(filename);
70
- }
71
-
72
- exports.loadSync = loadSync;
73
-
74
- // Serialization
75
- exports.encoder = require("./encoder");
76
- exports.decoder = require("./decoder");
77
- exports.verifier = require("./verifier");
78
- exports.converter = require("./converter");
79
-
80
- // Reflection
81
- exports.ReflectionObject = require("./object");
82
- exports.Namespace = require("./namespace");
83
- exports.Root = require("./root");
84
- exports.Enum = require("./enum");
85
- exports.Type = require("./type");
86
- exports.Field = require("./field");
87
- exports.OneOf = require("./oneof");
88
- exports.MapField = require("./mapfield");
89
- exports.Service = require("./service");
90
- exports.Method = require("./method");
91
-
92
- // Runtime
93
- exports.Message = require("./message");
94
- exports.wrappers = require("./wrappers");
95
-
96
- // Utility
97
- exports.types = require("./types");
98
- exports.util = require("./util");
99
-
100
- // Set up possibly cyclic reflection dependencies
101
- exports.ReflectionObject._configure(exports.Root);
102
- exports.Namespace._configure(exports.Type, exports.Service, exports.Enum);
103
- exports.Root._configure(exports.Type, undefined, {});
104
- exports.Field._configure(exports.Type);
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Build type, one of `"full"`, `"light"` or `"minimal"`.
5
- * @name build
6
- * @type {string}
7
- * @const
8
- */
9
- exports.build = "minimal";
10
-
11
- // Serialization
12
- exports.Writer = require("./writer");
13
- exports.BufferWriter = require("./writer_buffer");
14
- exports.Reader = require("./reader");
15
- exports.BufferReader = require("./reader_buffer");
16
-
17
- // Utility
18
- exports.util = require("./util/minimal");
19
- exports.rpc = require("./rpc");
20
- exports.roots = require("./roots");
21
- exports.configure = configure;
22
-
23
- /* istanbul ignore next */
24
- /**
25
- * Reconfigures the library according to the environment.
26
- * @returns {undefined}
27
- */
28
- function configure() {
29
- exports.util.LongBits._configure(exports.util.Long);
30
- exports.Writer._configure(exports.BufferWriter);
31
- exports.Reader._configure(exports.BufferReader);
32
- }
33
-
34
- // Set up buffer utility according to the environment
35
- configure();
@@ -1,12 +0,0 @@
1
- "use strict";
2
- exports = module.exports = require("./index-light");
3
-
4
- exports.build = "full";
5
-
6
- // Parser
7
- exports.tokenize = require("./tokenize");
8
- exports.parse = require("./parse");
9
- exports.common = require("./common");
10
-
11
- // Configure parser
12
- exports.Root._configure(exports.Type, exports.parse, exports.common);