tardis-machine 18.0.0 → 18.1.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 (228) 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/downloaddatasets.d.ts.map +1 -1
  30. package/node_modules/tardis-dev/dist/downloaddatasets.js +3 -1
  31. package/node_modules/tardis-dev/dist/downloaddatasets.js.map +1 -1
  32. package/node_modules/tardis-dev/dist/handy.d.ts +5 -2
  33. package/node_modules/tardis-dev/dist/handy.d.ts.map +1 -1
  34. package/node_modules/tardis-dev/dist/handy.js +77 -90
  35. package/node_modules/tardis-dev/dist/handy.js.map +1 -1
  36. package/node_modules/tardis-dev/dist/mappers/hyperliquid.d.ts +1 -1
  37. package/node_modules/tardis-dev/dist/mappers/hyperliquid.d.ts.map +1 -1
  38. package/node_modules/tardis-dev/dist/mappers/hyperliquid.js +15 -4
  39. package/node_modules/tardis-dev/dist/mappers/hyperliquid.js.map +1 -1
  40. package/node_modules/tardis-dev/dist/mappers/index.d.ts +1 -1
  41. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts +0 -7
  42. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts.map +1 -1
  43. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js +2 -70
  44. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js.map +1 -1
  45. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts +43 -0
  46. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts.map +1 -0
  47. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js +294 -0
  48. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js.map +1 -0
  49. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts +3 -3
  50. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
  51. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js +3 -3
  52. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js.map +1 -1
  53. package/node_modules/tardis-dev/dist/replay.d.ts.map +1 -1
  54. package/node_modules/tardis-dev/dist/replay.js +6 -4
  55. package/node_modules/tardis-dev/dist/replay.js.map +1 -1
  56. package/node_modules/tardis-dev/dist/worker.d.ts.map +1 -1
  57. package/node_modules/tardis-dev/dist/worker.js +7 -4
  58. package/node_modules/tardis-dev/dist/worker.js.map +1 -1
  59. package/node_modules/tardis-dev/dist/zstd.d.ts +3 -0
  60. package/node_modules/tardis-dev/dist/zstd.d.ts.map +1 -0
  61. package/node_modules/tardis-dev/dist/zstd.js +122 -0
  62. package/node_modules/tardis-dev/dist/zstd.js.map +1 -0
  63. package/node_modules/tardis-dev/package.json +3 -7
  64. package/node_modules/tardis-dev/src/debug.ts +16 -1
  65. package/node_modules/tardis-dev/src/downloaddatasets.ts +3 -1
  66. package/node_modules/tardis-dev/src/external-modules.d.ts +5 -0
  67. package/node_modules/tardis-dev/src/handy.ts +100 -93
  68. package/node_modules/tardis-dev/src/mappers/hyperliquid.ts +19 -5
  69. package/node_modules/tardis-dev/src/realtimefeeds/mexc.ts +2 -72
  70. package/node_modules/tardis-dev/src/realtimefeeds/mexcprotobuf.ts +364 -0
  71. package/node_modules/tardis-dev/src/realtimefeeds/realtimefeed.ts +5 -5
  72. package/node_modules/tardis-dev/src/replay.ts +6 -4
  73. package/node_modules/tardis-dev/src/worker.ts +7 -4
  74. package/node_modules/tardis-dev/src/zstd.ts +139 -0
  75. package/package.json +9 -35
  76. package/src/tardismachine.ts +25 -66
  77. package/src/ws/replay.ts +13 -8
  78. package/src/ws/replaynormalized.ts +8 -6
  79. package/src/ws/server.ts +173 -0
  80. package/src/ws/streamnormalized.ts +8 -6
  81. package/src/ws/subscriptionsmappers.ts +1 -1
  82. package/node_modules/follow-redirects/LICENSE +0 -18
  83. package/node_modules/follow-redirects/README.md +0 -157
  84. package/node_modules/follow-redirects/debug.js +0 -15
  85. package/node_modules/follow-redirects/http.js +0 -1
  86. package/node_modules/follow-redirects/https.js +0 -1
  87. package/node_modules/follow-redirects/index.js +0 -709
  88. package/node_modules/follow-redirects/package.json +0 -58
  89. package/node_modules/long/LICENSE +0 -202
  90. package/node_modules/long/README.md +0 -286
  91. package/node_modules/long/index.d.ts +0 -2
  92. package/node_modules/long/index.js +0 -1581
  93. package/node_modules/long/package.json +0 -58
  94. package/node_modules/long/types.d.ts +0 -474
  95. package/node_modules/long/umd/index.d.ts +0 -3
  96. package/node_modules/long/umd/index.js +0 -1622
  97. package/node_modules/long/umd/package.json +0 -3
  98. package/node_modules/long/umd/types.d.ts +0 -474
  99. package/node_modules/protobufjs/LICENSE +0 -39
  100. package/node_modules/protobufjs/README.md +0 -440
  101. package/node_modules/protobufjs/dist/light/protobuf.js +0 -9276
  102. package/node_modules/protobufjs/dist/light/protobuf.js.map +0 -1
  103. package/node_modules/protobufjs/dist/light/protobuf.min.js +0 -8
  104. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +0 -1
  105. package/node_modules/protobufjs/dist/minimal/protobuf.js +0 -3556
  106. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +0 -1
  107. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +0 -8
  108. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +0 -1
  109. package/node_modules/protobufjs/dist/protobuf.js +0 -11233
  110. package/node_modules/protobufjs/dist/protobuf.js.map +0 -1
  111. package/node_modules/protobufjs/dist/protobuf.min.js +0 -8
  112. package/node_modules/protobufjs/dist/protobuf.min.js.map +0 -1
  113. package/node_modules/protobufjs/ext/README.md +0 -70
  114. package/node_modules/protobufjs/ext/debug/README.md +0 -4
  115. package/node_modules/protobufjs/ext/debug/index.js +0 -71
  116. package/node_modules/protobufjs/ext/descriptor/README.md +0 -5
  117. package/node_modules/protobufjs/ext/descriptor/index.d.ts +0 -2
  118. package/node_modules/protobufjs/ext/descriptor/index.js +0 -2
  119. package/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
  120. package/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -417
  121. package/node_modules/protobufjs/ext/descriptor.js +0 -1356
  122. package/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
  123. package/node_modules/protobufjs/ext/protojson.d.ts +0 -20
  124. package/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
  125. package/node_modules/protobufjs/ext/protojson.js +0 -951
  126. package/node_modules/protobufjs/ext/textformat.d.ts +0 -19
  127. package/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
  128. package/node_modules/protobufjs/ext/textformat.js +0 -1276
  129. package/node_modules/protobufjs/google/LICENSE +0 -27
  130. package/node_modules/protobufjs/google/README.md +0 -1
  131. package/node_modules/protobufjs/google/api/annotations.json +0 -85
  132. package/node_modules/protobufjs/google/api/annotations.proto +0 -11
  133. package/node_modules/protobufjs/google/api/http.json +0 -87
  134. package/node_modules/protobufjs/google/api/http.proto +0 -31
  135. package/node_modules/protobufjs/google/protobuf/api.json +0 -124
  136. package/node_modules/protobufjs/google/protobuf/api.proto +0 -34
  137. package/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
  138. package/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
  139. package/node_modules/protobufjs/google/protobuf/descriptor.json +0 -1465
  140. package/node_modules/protobufjs/google/protobuf/descriptor.proto +0 -527
  141. package/node_modules/protobufjs/google/protobuf/source_context.json +0 -21
  142. package/node_modules/protobufjs/google/protobuf/source_context.proto +0 -7
  143. package/node_modules/protobufjs/google/protobuf/type.json +0 -209
  144. package/node_modules/protobufjs/google/protobuf/type.proto +0 -89
  145. package/node_modules/protobufjs/index.d.ts +0 -3203
  146. package/node_modules/protobufjs/index.js +0 -4
  147. package/node_modules/protobufjs/light.d.ts +0 -2
  148. package/node_modules/protobufjs/light.js +0 -4
  149. package/node_modules/protobufjs/minimal.d.ts +0 -2
  150. package/node_modules/protobufjs/minimal.js +0 -4
  151. package/node_modules/protobufjs/package.json +0 -93
  152. package/node_modules/protobufjs/src/common.js +0 -405
  153. package/node_modules/protobufjs/src/converter.js +0 -352
  154. package/node_modules/protobufjs/src/decoder.js +0 -279
  155. package/node_modules/protobufjs/src/encoder.js +0 -123
  156. package/node_modules/protobufjs/src/enum.js +0 -239
  157. package/node_modules/protobufjs/src/field.js +0 -505
  158. package/node_modules/protobufjs/src/index-light.js +0 -104
  159. package/node_modules/protobufjs/src/index-minimal.js +0 -35
  160. package/node_modules/protobufjs/src/index.js +0 -12
  161. package/node_modules/protobufjs/src/mapfield.js +0 -144
  162. package/node_modules/protobufjs/src/message.js +0 -137
  163. package/node_modules/protobufjs/src/method.js +0 -183
  164. package/node_modules/protobufjs/src/namespace.js +0 -574
  165. package/node_modules/protobufjs/src/object.js +0 -392
  166. package/node_modules/protobufjs/src/oneof.js +0 -233
  167. package/node_modules/protobufjs/src/parse.js +0 -1111
  168. package/node_modules/protobufjs/src/reader.js +0 -788
  169. package/node_modules/protobufjs/src/reader_buffer.js +0 -77
  170. package/node_modules/protobufjs/src/root.js +0 -424
  171. package/node_modules/protobufjs/src/roots.js +0 -18
  172. package/node_modules/protobufjs/src/rpc/service.js +0 -155
  173. package/node_modules/protobufjs/src/rpc.js +0 -36
  174. package/node_modules/protobufjs/src/service.js +0 -206
  175. package/node_modules/protobufjs/src/tokenize.js +0 -421
  176. package/node_modules/protobufjs/src/type.js +0 -676
  177. package/node_modules/protobufjs/src/types.js +0 -196
  178. package/node_modules/protobufjs/src/typescript.js +0 -25
  179. package/node_modules/protobufjs/src/util/aspromise.d.ts +0 -13
  180. package/node_modules/protobufjs/src/util/aspromise.js +0 -52
  181. package/node_modules/protobufjs/src/util/base64.d.ts +0 -32
  182. package/node_modules/protobufjs/src/util/base64.js +0 -146
  183. package/node_modules/protobufjs/src/util/codegen.d.ts +0 -31
  184. package/node_modules/protobufjs/src/util/codegen.js +0 -118
  185. package/node_modules/protobufjs/src/util/eventemitter.d.ts +0 -45
  186. package/node_modules/protobufjs/src/util/eventemitter.js +0 -86
  187. package/node_modules/protobufjs/src/util/fetch.d.ts +0 -56
  188. package/node_modules/protobufjs/src/util/fetch.js +0 -112
  189. package/node_modules/protobufjs/src/util/float.d.ts +0 -83
  190. package/node_modules/protobufjs/src/util/float.js +0 -335
  191. package/node_modules/protobufjs/src/util/fs.js +0 -11
  192. package/node_modules/protobufjs/src/util/longbits.js +0 -204
  193. package/node_modules/protobufjs/src/util/minimal.js +0 -511
  194. package/node_modules/protobufjs/src/util/path.d.ts +0 -22
  195. package/node_modules/protobufjs/src/util/path.js +0 -100
  196. package/node_modules/protobufjs/src/util/patterns.js +0 -7
  197. package/node_modules/protobufjs/src/util/pool.d.ts +0 -32
  198. package/node_modules/protobufjs/src/util/pool.js +0 -48
  199. package/node_modules/protobufjs/src/util/utf8.d.ts +0 -24
  200. package/node_modules/protobufjs/src/util/utf8.js +0 -190
  201. package/node_modules/protobufjs/src/util.js +0 -264
  202. package/node_modules/protobufjs/src/verifier.js +0 -185
  203. package/node_modules/protobufjs/src/wrappers.js +0 -106
  204. package/node_modules/protobufjs/src/writer.js +0 -700
  205. package/node_modules/protobufjs/src/writer_buffer.js +0 -100
  206. package/node_modules/protobufjs/tsconfig.json +0 -6
  207. package/node_modules/uWebSockets.js/ESM_wrapper.mjs +0 -53
  208. package/node_modules/uWebSockets.js/LICENSE +0 -201
  209. package/node_modules/uWebSockets.js/README.md +0 -6
  210. package/node_modules/uWebSockets.js/index.d.ts +0 -468
  211. package/node_modules/uWebSockets.js/package.json +0 -12
  212. package/node_modules/uWebSockets.js/source_commit +0 -1
  213. package/node_modules/uWebSockets.js/uws.js +0 -76
  214. package/node_modules/uWebSockets.js/uws_darwin_arm64_127.node +0 -0
  215. package/node_modules/uWebSockets.js/uws_darwin_arm64_137.node +0 -0
  216. package/node_modules/uWebSockets.js/uws_darwin_arm64_147.node +0 -0
  217. package/node_modules/uWebSockets.js/uws_darwin_x64_127.node +0 -0
  218. package/node_modules/uWebSockets.js/uws_darwin_x64_137.node +0 -0
  219. package/node_modules/uWebSockets.js/uws_darwin_x64_147.node +0 -0
  220. package/node_modules/uWebSockets.js/uws_linux_arm64_127.node +0 -0
  221. package/node_modules/uWebSockets.js/uws_linux_arm64_137.node +0 -0
  222. package/node_modules/uWebSockets.js/uws_linux_arm64_147.node +0 -0
  223. package/node_modules/uWebSockets.js/uws_linux_x64_127.node +0 -0
  224. package/node_modules/uWebSockets.js/uws_linux_x64_137.node +0 -0
  225. package/node_modules/uWebSockets.js/uws_linux_x64_147.node +0 -0
  226. package/node_modules/uWebSockets.js/uws_win32_x64_127.node +0 -0
  227. package/node_modules/uWebSockets.js/uws_win32_x64_137.node +0 -0
  228. package/node_modules/uWebSockets.js/uws_win32_x64_147.node +0 -0
@@ -1,1111 +0,0 @@
1
- "use strict";
2
- module.exports = parse;
3
-
4
- parse.filename = null;
5
- parse.defaults = { keepCase: false };
6
-
7
- var tokenize = require("./tokenize"),
8
- Root = require("./root"),
9
- Type = require("./type"),
10
- Field = require("./field"),
11
- MapField = require("./mapfield"),
12
- OneOf = require("./oneof"),
13
- Enum = require("./enum"),
14
- Service = require("./service"),
15
- Method = require("./method"),
16
- ReflectionObject = require("./object"),
17
- types = require("./types"),
18
- util = require("./util");
19
-
20
- var base10Re = /^[1-9][0-9]*$/,
21
- base10NegRe = /^-?[1-9][0-9]*$/,
22
- base16Re = /^0[x][0-9a-fA-F]+$/,
23
- base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
24
- base8Re = /^0[0-7]+$/,
25
- base8NegRe = /^-?0[0-7]+$/,
26
- numberRe = util.patterns.numberRe,
27
- nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
28
- typeRefRe = util.patterns.typeRefRe;
29
-
30
- var maxFieldId = 536870911, // 2^29 - 1
31
- maxEnumId = 2147483647; // 2^31 - 1
32
-
33
- /**
34
- * Result object returned from {@link parse}.
35
- * @interface IParserResult
36
- * @property {string|undefined} package Package name, if declared
37
- * @property {string[]|undefined} imports Imports, if any
38
- * @property {string[]|undefined} weakImports Weak imports, if any
39
- * @property {Root} root Populated root instance
40
- */
41
-
42
- /**
43
- * Options modifying the behavior of {@link parse}.
44
- * @interface IParseOptions
45
- * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
46
- * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
47
- * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
48
- */
49
-
50
- /**
51
- * Options modifying the behavior of JSON serialization.
52
- * @interface IToJSONOptions
53
- * @property {boolean} [keepComments=false] Serializes comments.
54
- */
55
-
56
- /**
57
- * Parses the given .proto source and returns an object with the parsed contents.
58
- * @param {string} source Source contents
59
- * @param {Root} root Root to populate
60
- * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
61
- * @returns {IParserResult} Parser result
62
- * @property {string} filename=null Currently processing file name for error reporting, if known
63
- * @property {IParseOptions} defaults Default {@link IParseOptions}
64
- */
65
- function parse(source, root, options) {
66
- /* eslint-disable callback-return */
67
- if (!(root instanceof Root)) {
68
- options = root;
69
- root = new Root();
70
- }
71
- if (!options)
72
- options = parse.defaults;
73
-
74
- var preferTrailingComment = options.preferTrailingComment || false;
75
- var tn = tokenize(source, options.alternateCommentMode || false),
76
- next = tn.next,
77
- push = tn.push,
78
- peek = tn.peek,
79
- skip = tn.skip,
80
- cmnt = tn.cmnt;
81
-
82
- var head = true,
83
- pkg,
84
- imports,
85
- weakImports,
86
- edition = "proto2";
87
-
88
- var ptr = root;
89
-
90
- var topLevelObjects = [];
91
- var topLevelOptions = {};
92
-
93
- var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
94
-
95
- function resolveFileFeatures() {
96
- topLevelObjects.forEach(obj => {
97
- obj._edition = edition;
98
- Object.keys(topLevelOptions).forEach(opt => {
99
- if (obj.getOption(opt) !== undefined) return;
100
- obj.setOption(opt, topLevelOptions[opt], true);
101
- });
102
- });
103
- }
104
-
105
- /* istanbul ignore next */
106
- function illegal(token, name, insideTryCatch) {
107
- var filename = parse.filename;
108
- if (!insideTryCatch)
109
- parse.filename = null;
110
- return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
111
- }
112
-
113
- function readString() {
114
- var values = [],
115
- token;
116
- do {
117
- /* istanbul ignore if */
118
- if ((token = next()) !== "\"" && token !== "'")
119
- throw illegal(token);
120
-
121
- values.push(next());
122
- skip(token);
123
- token = peek();
124
- } while (token === "\"" || token === "'");
125
- return values.join("");
126
- }
127
-
128
- function readValue(acceptTypeRef) {
129
- var token = next();
130
- switch (token) {
131
- case "'":
132
- case "\"":
133
- push(token);
134
- return readString();
135
- case "true": case "TRUE":
136
- return true;
137
- case "false": case "FALSE":
138
- return false;
139
- }
140
- try {
141
- return parseNumber(token, /* insideTryCatch */ true);
142
- } catch (e) {
143
- /* istanbul ignore else */
144
- if (acceptTypeRef && typeRefRe.test(token))
145
- return token;
146
-
147
- /* istanbul ignore next */
148
- throw illegal(token, "value");
149
- }
150
- }
151
-
152
- function readRanges(target, acceptStrings, max, acceptNegative) {
153
- var token, start;
154
- do {
155
- if (acceptStrings && ((token = peek()) === "\"" || token === "'")) {
156
- var str = readString();
157
- target.push(str);
158
- if (edition >= 2023) {
159
- throw illegal(str, "id");
160
- }
161
- } else {
162
- try {
163
- target.push([ start = parseId(next(), acceptNegative, max), skip("to", true) ? parseId(next(), acceptNegative, max) : start ]);
164
- } catch (err) {
165
- if (acceptStrings && typeRefRe.test(token) && edition >= 2023) {
166
- target.push(token);
167
- } else {
168
- throw err;
169
- }
170
- }
171
- }
172
- } while (skip(",", true));
173
- var dummy = {options: undefined};
174
- dummy.setOption = function(name, value) {
175
- if (this.options === undefined) this.options = {};
176
- this.options[name] = value;
177
- };
178
- ifBlock(
179
- dummy,
180
- function parseRange_block(token) {
181
- /* istanbul ignore else */
182
- if (token === "option") {
183
- parseOption(dummy, token); // skip
184
- skip(";");
185
- } else
186
- throw illegal(token);
187
- },
188
- function parseRange_line() {
189
- parseInlineOptions(dummy); // skip
190
- });
191
- }
192
-
193
- function parseNumber(token, insideTryCatch) {
194
- var sign = 1;
195
- if (token.charAt(0) === "-") {
196
- sign = -1;
197
- token = token.substring(1);
198
- }
199
- switch (token) {
200
- case "inf": case "INF": case "Inf":
201
- return sign * Infinity;
202
- case "nan": case "NAN": case "Nan": case "NaN":
203
- return NaN;
204
- case "0":
205
- return 0;
206
- }
207
- if (base10Re.test(token))
208
- return sign * parseInt(token, 10);
209
- if (base16Re.test(token))
210
- return sign * parseInt(token, 16);
211
- if (base8Re.test(token))
212
- return sign * parseInt(token, 8);
213
-
214
- /* istanbul ignore else */
215
- if (numberRe.test(token))
216
- return sign * parseFloat(token);
217
-
218
- /* istanbul ignore next */
219
- throw illegal(token, "number", insideTryCatch);
220
- }
221
-
222
- function parseId(token, acceptNegative, max) {
223
- if (token === null) {
224
- throw illegal(token, "end of input");
225
- }
226
- switch (token) {
227
- case "max": case "MAX": case "Max":
228
- return max || maxFieldId;
229
- case "0":
230
- return 0;
231
- }
232
-
233
- /* istanbul ignore if */
234
- if (!acceptNegative && token.charAt(0) === "-")
235
- throw illegal(token, "id");
236
-
237
- if (base10NegRe.test(token))
238
- return parseInt(token, 10);
239
- if (base16NegRe.test(token))
240
- return parseInt(token, 16);
241
-
242
- /* istanbul ignore else */
243
- if (base8NegRe.test(token))
244
- return parseInt(token, 8);
245
-
246
- /* istanbul ignore next */
247
- throw illegal(token, "id");
248
- }
249
-
250
- function parsePackage() {
251
- /* istanbul ignore if */
252
- if (pkg !== undefined)
253
- throw illegal("package");
254
-
255
- pkg = next();
256
-
257
- /* istanbul ignore if */
258
- if (pkg === null || !typeRefRe.test(pkg))
259
- throw illegal(pkg, "name");
260
-
261
- ptr = ptr.define(pkg);
262
-
263
- skip(";");
264
- }
265
-
266
- function parseImport() {
267
- var token = peek();
268
- var whichImports;
269
- switch (token) {
270
- case "option":
271
- if (edition < "2024") {
272
- throw illegal("option");
273
- }
274
- // Import options are only used for resolving options, which we don't
275
- // do. We can just throw them out.
276
- next();
277
- readString();
278
- skip(";");
279
- return;
280
- case "weak":
281
- whichImports = weakImports || (weakImports = []);
282
- next();
283
- break;
284
- case "public":
285
- next();
286
- // eslint-disable-next-line no-fallthrough
287
- default:
288
- whichImports = imports || (imports = []);
289
- break;
290
- }
291
- token = readString();
292
- skip(";");
293
- whichImports.push(token);
294
- }
295
-
296
- function parseSyntax() {
297
- skip("=");
298
- edition = readString();
299
-
300
- /* istanbul ignore if */
301
- if (edition < 2023)
302
- throw illegal(edition, "syntax");
303
-
304
- skip(";");
305
- }
306
-
307
- function parseEdition() {
308
- skip("=");
309
- edition = readString();
310
- const supportedEditions = ["2023", "2024"];
311
-
312
- /* istanbul ignore if */
313
- if (!supportedEditions.includes(edition))
314
- throw illegal(edition, "edition");
315
-
316
- skip(";");
317
- }
318
-
319
-
320
- function parseCommon(parent, token, depth) {
321
- if (depth === undefined)
322
- depth = 0;
323
- // depth is checked by dispatched functions
324
- switch (token) {
325
-
326
- case "option":
327
- parseOption(parent, token);
328
- skip(";");
329
- return true;
330
-
331
- case "message":
332
- parseType(parent, token, depth + 1);
333
- return true;
334
-
335
- case "enum":
336
- parseEnum(parent, token);
337
- return true;
338
-
339
- case "export":
340
- case "local":
341
- if (edition < "2024") {
342
- return false;
343
- }
344
- token = next();
345
- if (token === "export" || token === "local") {
346
- return false;
347
- }
348
- if (token !== "message" && token !== "enum") {
349
- return false;
350
- }
351
- /* eslint-disable no-warning-comments */
352
- // TODO: actually enforce visiblity modifiers like protoc does.
353
- return parseCommon(parent, token, depth);
354
-
355
- case "service":
356
- parseService(parent, token, depth + 1);
357
- return true;
358
-
359
- case "extend":
360
- parseExtension(parent, token, depth);
361
- return true;
362
- }
363
- return false;
364
- }
365
-
366
- function ifBlock(obj, fnIf, fnElse) {
367
- var trailingLine = tn.line;
368
- if (obj) {
369
- if(typeof obj.comment !== "string") {
370
- obj.comment = cmnt(); // try block-type comment
371
- }
372
- obj.filename = parse.filename;
373
- }
374
- if (skip("{", true)) {
375
- var token;
376
- while ((token = next()) !== "}")
377
- fnIf(token);
378
- skip(";", true);
379
- } else {
380
- if (fnElse)
381
- fnElse();
382
- skip(";");
383
- if (obj && (typeof obj.comment !== "string" || preferTrailingComment))
384
- obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment
385
- }
386
- }
387
-
388
- function parseType(parent, token, depth) {
389
- if (depth === undefined)
390
- depth = 0;
391
- if (depth > util.nestingLimit)
392
- throw Error("max depth exceeded");
393
-
394
- /* istanbul ignore if */
395
- if ((token = next()) === null || !nameRe.test(token))
396
- throw illegal(token, "type name");
397
-
398
- var type = new Type(token);
399
- ifBlock(type, function parseType_block(token) {
400
- if (parseCommon(type, token, depth))
401
- return;
402
-
403
- switch (token) {
404
-
405
- case ";":
406
- break;
407
-
408
- case "map":
409
- parseMapField(type, token);
410
- break;
411
-
412
- case "required":
413
- if (edition !== "proto2")
414
- throw illegal(token);
415
- /* eslint-disable no-fallthrough */
416
- case "repeated":
417
- parseField(type, token, undefined, depth + 1);
418
- break;
419
-
420
- case "optional":
421
- /* istanbul ignore if */
422
- if (edition === "proto3") {
423
- parseField(type, "proto3_optional", undefined, depth + 1);
424
- } else if (edition !== "proto2") {
425
- throw illegal(token);
426
- } else {
427
- parseField(type, "optional", undefined, depth + 1);
428
- }
429
- break;
430
-
431
- case "oneof":
432
- parseOneOf(type, token, depth + 1);
433
- break;
434
-
435
- case "extensions":
436
- readRanges(type.extensions || (type.extensions = []));
437
- break;
438
-
439
- case "reserved":
440
- readRanges(type.reserved || (type.reserved = []), true);
441
- break;
442
-
443
- default:
444
- /* istanbul ignore if */
445
- if (edition === "proto2" || !typeRefRe.test(token)) {
446
- throw illegal(token);
447
- }
448
-
449
- push(token);
450
- parseField(type, "optional", undefined, depth + 1);
451
- break;
452
- }
453
- });
454
- parent.add(type);
455
- if (parent === ptr) {
456
- topLevelObjects.push(type);
457
- }
458
- }
459
-
460
- function parseField(parent, rule, extend, depth) {
461
- var type = next();
462
- if (type === null) {
463
- throw illegal(type, "end of input");
464
- }
465
- if (type === "group") {
466
- parseGroup(parent, rule, extend, depth);
467
- return;
468
- }
469
- // Type names can consume multiple tokens, in multiple variants:
470
- // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
471
- // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
472
- // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
473
- // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
474
- // Keep reading tokens until we get a type name with no period at the end,
475
- // and the next token does not start with a period.
476
- while (type.endsWith(".") || (peek() || "").startsWith(".")) {
477
- var part = next();
478
- if (part === null) {
479
- throw illegal(part, "end of input");
480
- }
481
- type += part;
482
- }
483
-
484
- /* istanbul ignore if */
485
- if (!typeRefRe.test(type))
486
- throw illegal(type, "type");
487
-
488
- var name = next();
489
- if (name === null) {
490
- throw illegal(name, "end of input");
491
- }
492
-
493
- /* istanbul ignore if */
494
-
495
- if (!nameRe.test(name))
496
- throw illegal(name, "name");
497
-
498
- var protoName = name;
499
- name = applyCase(name);
500
- skip("=");
501
-
502
- var field = new Field(name, parseId(next()), type, rule === "proto3_optional" ? "optional" : rule, extend);
503
- if (protoName !== name)
504
- field.protoName = protoName;
505
-
506
- ifBlock(field, function parseField_block(token) {
507
-
508
- /* istanbul ignore else */
509
- if (token === "option") {
510
- parseOption(field, token);
511
- skip(";");
512
- } else
513
- throw illegal(token);
514
-
515
- }, function parseField_line() {
516
- parseInlineOptions(field);
517
- });
518
-
519
- if (rule === "proto3_optional") {
520
- // for proto3 optional fields, we create a single-member Oneof to mimic "optional" behavior
521
- var oneof = new OneOf("_" + name);
522
- field.setOption("proto3_optional", true);
523
- oneof.add(field);
524
- parent.add(oneof);
525
- } else {
526
- parent.add(field);
527
- }
528
- if (parent === ptr) {
529
- topLevelObjects.push(field);
530
- }
531
- }
532
-
533
- function parseGroup(parent, rule, extend, depth) {
534
- if (depth === undefined)
535
- depth = 0;
536
- if (depth > util.nestingLimit)
537
- throw Error("max depth exceeded");
538
- if (edition >= 2023) {
539
- throw illegal("group");
540
- }
541
- var name = next();
542
-
543
- /* istanbul ignore if */
544
- if (name === null || !nameRe.test(name))
545
- throw illegal(name, "name");
546
-
547
- var fieldName = util.lcFirst(name);
548
- if (name === fieldName)
549
- name = util.ucFirst(name);
550
- skip("=");
551
- var id = parseId(next());
552
- var type = new Type(name);
553
- type.group = true;
554
- var field = new Field(fieldName, id, name, rule, extend);
555
- field.filename = parse.filename;
556
- ifBlock(type, function parseGroup_block(token) {
557
- switch (token) {
558
-
559
- case ";":
560
- break;
561
-
562
- case "map":
563
- parseMapField(type);
564
- break;
565
-
566
- case "option":
567
- parseOption(type, token);
568
- skip(";");
569
- break;
570
- case "required":
571
- case "repeated":
572
- parseField(type, token, undefined, depth + 1);
573
- break;
574
-
575
- case "optional":
576
- /* istanbul ignore if */
577
- if (edition === "proto3") {
578
- parseField(type, "proto3_optional", undefined, depth + 1);
579
- } else {
580
- parseField(type, "optional", undefined, depth + 1);
581
- }
582
- break;
583
-
584
- case "message":
585
- parseType(type, token, depth + 1);
586
- break;
587
-
588
- case "enum":
589
- parseEnum(type, token);
590
- break;
591
-
592
- case "reserved":
593
- readRanges(type.reserved || (type.reserved = []), true);
594
- break;
595
-
596
- case "export":
597
- case "local":
598
- if (edition < "2024") {
599
- throw illegal(token);
600
- }
601
- token = next();
602
- switch (token) {
603
- case "message":
604
- parseType(type, token, depth + 1);
605
- break;
606
- case "enum":
607
- parseType(type, token, depth + 1);
608
- break;
609
- default:
610
- throw illegal(token);
611
- }
612
- break;
613
-
614
- /* istanbul ignore next */
615
- default:
616
- throw illegal(token); // there are no groups with proto3 semantics
617
- }
618
- });
619
- parent.add(type)
620
- .add(field);
621
- if (parent === ptr) {
622
- topLevelObjects.push(type);
623
- topLevelObjects.push(field);
624
- }
625
- }
626
-
627
- function parseMapField(parent) {
628
- skip("<");
629
- var keyType = next();
630
-
631
- /* istanbul ignore if */
632
- if (types.mapKey[keyType] === undefined)
633
- throw illegal(keyType, "type");
634
-
635
- skip(",");
636
- var valueType = next();
637
-
638
- /* istanbul ignore if */
639
- if (!typeRefRe.test(valueType))
640
- throw illegal(valueType, "type");
641
-
642
- skip(">");
643
- var name = next();
644
-
645
- /* istanbul ignore if */
646
- if (name === null || !nameRe.test(name))
647
- throw illegal(name, "name");
648
-
649
- skip("=");
650
- var protoName = name;
651
- name = applyCase(name);
652
- var field = new MapField(name, parseId(next()), keyType, valueType);
653
- if (protoName !== name)
654
- field.protoName = protoName;
655
- ifBlock(field, function parseMapField_block(token) {
656
-
657
- /* istanbul ignore else */
658
- if (token === "option") {
659
- parseOption(field, token);
660
- skip(";");
661
- } else
662
- throw illegal(token);
663
-
664
- }, function parseMapField_line() {
665
- parseInlineOptions(field);
666
- });
667
- parent.add(field);
668
- }
669
-
670
- function parseOneOf(parent, token, depth) {
671
-
672
- /* istanbul ignore if */
673
- if ((token = next()) === null || !nameRe.test(token))
674
- throw illegal(token, "name");
675
-
676
- var oneof = new OneOf(applyCase(token));
677
- ifBlock(oneof, function parseOneOf_block(token) {
678
- if (token === "option") {
679
- parseOption(oneof, token);
680
- skip(";");
681
- } else {
682
- push(token);
683
- parseField(oneof, "optional", undefined, depth);
684
- }
685
- });
686
- parent.add(oneof);
687
- }
688
-
689
- function parseEnum(parent, token) {
690
-
691
- /* istanbul ignore if */
692
- if ((token = next()) === null || !nameRe.test(token))
693
- throw illegal(token, "name");
694
-
695
- var enm = new Enum(token),
696
- values = [];
697
- ifBlock(enm, function parseEnum_block(token) {
698
- switch(token) {
699
- case ";":
700
- break;
701
-
702
- case "option":
703
- parseOption(enm, token);
704
- skip(";");
705
- break;
706
-
707
- case "reserved":
708
- readRanges(enm.reserved || (enm.reserved = []), true, maxEnumId, true);
709
- if(enm.reserved === undefined) enm.reserved = [];
710
- break;
711
-
712
- default:
713
- values.push(parseEnumValue(token));
714
- }
715
- });
716
- for (var i = 0; i < values.length; ++i)
717
- enm.add(values[i].name, values[i].id, values[i].comment, values[i].options);
718
- parent.add(enm);
719
- if (parent === ptr) {
720
- topLevelObjects.push(enm);
721
- }
722
- }
723
-
724
- function parseEnumValue(token) {
725
-
726
- /* istanbul ignore if */
727
- if (!nameRe.test(token))
728
- throw illegal(token, "name");
729
-
730
- skip("=");
731
- var value = parseId(next(), true),
732
- dummy = {
733
- options: undefined
734
- };
735
- dummy.getOption = function(name) {
736
- return this.options[name];
737
- };
738
- dummy.setOption = function(name, value) {
739
- ReflectionObject.prototype.setOption.call(dummy, name, value);
740
- };
741
- dummy.setParsedOption = function() {
742
- return undefined;
743
- };
744
- ifBlock(dummy, function parseEnumValue_block(token) {
745
-
746
- /* istanbul ignore else */
747
- if (token === "option") {
748
- parseOption(dummy, token); // skip
749
- skip(";");
750
- } else
751
- throw illegal(token);
752
-
753
- }, function parseEnumValue_line() {
754
- parseInlineOptions(dummy); // skip
755
- });
756
- return {
757
- name: token,
758
- id: value,
759
- comment: dummy.comment,
760
- options: dummy.parsedOptions || dummy.options
761
- };
762
- }
763
-
764
- function parseOption(parent, token) {
765
- var option;
766
- var propName;
767
- var isOption = true;
768
- if (token === "option") {
769
- token = next();
770
- }
771
-
772
- while (token !== "=") {
773
- if (token === null) {
774
- throw illegal(token, "end of input");
775
- }
776
- if (token === "(") {
777
- var parensValue = next();
778
- skip(")");
779
- token = "(" + parensValue + ")";
780
- }
781
- if (isOption) {
782
- isOption = false;
783
- if (token.includes(".") && !token.includes("(")) {
784
- var tokens = token.split(".");
785
- option = tokens[0] + ".";
786
- token = tokens[1];
787
- continue;
788
- }
789
- option = token;
790
- } else {
791
- propName = propName ? propName += token : token;
792
- }
793
- token = next();
794
- }
795
- var name = propName ? option.concat(propName) : option;
796
- var optionValue = parseOptionValue(parent, name);
797
- propName = propName && propName[0] === "." ? propName.slice(1) : propName;
798
- option = option && option[option.length - 1] === "." ? option.slice(0, -1) : option;
799
- setParsedOption(parent, option, optionValue, propName);
800
- }
801
-
802
- function parseOptionValue(parent, name, depth) {
803
- if (depth === undefined)
804
- depth = 0;
805
- if (depth > util.recursionLimit)
806
- throw Error("max depth exceeded");
807
- // { a: "foo" b { c: "bar" } }
808
- if (skip("{", true)) {
809
- var objectResult = {};
810
-
811
- while (!skip("}", true)) {
812
- token = next();
813
- var propName;
814
- if (token === null)
815
- throw illegal(token, "end of input");
816
- if (token === "[") {
817
- token = next();
818
- // Extension name or, for Any, a type URL: "<prefix>/<fully.qualified.Type>".
819
- var slash = token === null ? -1 : token.lastIndexOf("/");
820
- if (token === null || !typeRefRe.test(slash < 0 ? token : token.slice(slash + 1)))
821
- throw illegal(token, "name");
822
- propName = "[" + token + "]";
823
- skip("]");
824
- } else {
825
- /* istanbul ignore if */
826
- if (!nameRe.test(token)) {
827
- throw illegal(token, "name");
828
- }
829
- propName = token;
830
- }
831
-
832
- var value;
833
-
834
- skip(":", true);
835
-
836
- if (peek() === "{") {
837
- // option (my_option) = {
838
- // repeated_value: [ "foo", "bar" ]
839
- // };
840
- value = parseOptionValue(parent, name + "." + propName, depth + 1);
841
- } else if (peek() === "[") {
842
- value = [];
843
- var lastValue,
844
- lastValueIsAggregate;
845
- if (skip("[", true)) {
846
- if (!skip("]", true)) {
847
- do {
848
- lastValueIsAggregate = peek() === "{";
849
- lastValue = lastValueIsAggregate
850
- ? parseOptionValue(parent, name + "." + propName, depth + 1)
851
- : readValue(true);
852
- value.push(lastValue);
853
- } while (skip(",", true));
854
- skip("]");
855
- if (typeof lastValue !== "undefined") {
856
- if (!lastValueIsAggregate)
857
- setOption(parent, name + "." + propName, lastValue);
858
- }
859
- }
860
- }
861
- } else {
862
- value = readValue(true);
863
- setOption(parent, name + "." + propName, value);
864
- }
865
-
866
- var prevValue = Object.prototype.hasOwnProperty.call(objectResult, propName)
867
- ? objectResult[propName]
868
- : undefined;
869
-
870
- if (prevValue)
871
- value = [].concat(prevValue).concat(value);
872
-
873
- if (propName !== "__proto__")
874
- objectResult[propName] = value;
875
-
876
- // Semicolons and commas can be optional
877
- skip(",", true);
878
- skip(";", true);
879
- }
880
-
881
- return objectResult;
882
- }
883
-
884
- var simpleValue = readValue(true);
885
- setOption(parent, name, simpleValue);
886
- return simpleValue;
887
- // Does not enforce a delimiter to be universal
888
- }
889
-
890
- function setOption(parent, name, value) {
891
- if (ptr === parent && /^features\./.test(name)) {
892
- topLevelOptions[name] = value;
893
- return;
894
- }
895
- // lift json_name onto Field
896
- if (name === "json_name" && parent instanceof Field) {
897
- parent.jsonName = value;
898
- }
899
- if (parent.setOption)
900
- parent.setOption(name, value);
901
- }
902
-
903
- function setParsedOption(parent, name, value, propName) {
904
- if (parent.setParsedOption)
905
- parent.setParsedOption(name, value, propName);
906
- }
907
-
908
- function parseInlineOptions(parent) {
909
- if (skip("[", true)) {
910
- do {
911
- parseOption(parent, "option");
912
- } while (skip(",", true));
913
- skip("]");
914
- }
915
- return parent;
916
- }
917
-
918
- function parseService(parent, token, depth) {
919
- if (depth === undefined)
920
- depth = 0;
921
- if (depth > util.recursionLimit)
922
- throw Error("max depth exceeded");
923
-
924
- /* istanbul ignore if */
925
- if ((token = next()) === null || !nameRe.test(token))
926
- throw illegal(token, "service name");
927
-
928
- var service = new Service(token);
929
- ifBlock(service, function parseService_block(token) {
930
- if (parseCommon(service, token, depth)) {
931
- return;
932
- }
933
-
934
- /* istanbul ignore else */
935
- if (token === ";")
936
- return;
937
- if (token === "rpc")
938
- parseMethod(service, token);
939
- else
940
- throw illegal(token);
941
- });
942
- parent.add(service);
943
- if (parent === ptr) {
944
- topLevelObjects.push(service);
945
- }
946
- }
947
-
948
- function parseMethod(parent, token) {
949
- // Get the comment of the preceding line now (if one exists) in case the
950
- // method is defined across multiple lines.
951
- var commentText = cmnt();
952
-
953
- var type = token;
954
-
955
- /* istanbul ignore if */
956
- if (!nameRe.test(token = next()))
957
- throw illegal(token, "name");
958
-
959
- var name = token,
960
- requestType, requestStream,
961
- responseType, responseStream;
962
-
963
- skip("(");
964
- if (skip("stream", true))
965
- requestStream = true;
966
-
967
- /* istanbul ignore if */
968
- if (!typeRefRe.test(token = next()))
969
- throw illegal(token);
970
-
971
- requestType = token;
972
- skip(")"); skip("returns"); skip("(");
973
- if (skip("stream", true))
974
- responseStream = true;
975
-
976
- /* istanbul ignore if */
977
- if (!typeRefRe.test(token = next()))
978
- throw illegal(token);
979
-
980
- responseType = token;
981
- skip(")");
982
-
983
- var method = new Method(name, type, requestType, responseType, requestStream, responseStream);
984
- method.comment = commentText;
985
- ifBlock(method, function parseMethod_block(token) {
986
-
987
- /* istanbul ignore else */
988
- if (token === ";")
989
- return;
990
- if (token === "option") {
991
- parseOption(method, token);
992
- skip(";");
993
- } else
994
- throw illegal(token);
995
-
996
- });
997
- parent.add(method);
998
- }
999
-
1000
- function parseExtension(parent, token, depth) {
1001
-
1002
- /* istanbul ignore if */
1003
- if ((token = next()) === null || !typeRefRe.test(token))
1004
- throw illegal(token, "reference");
1005
-
1006
- var reference = token;
1007
- ifBlock(null, function parseExtension_block(token) {
1008
- switch (token) {
1009
-
1010
- case "required":
1011
- case "repeated":
1012
- parseField(parent, token, reference, depth + 1);
1013
- break;
1014
-
1015
- case "optional":
1016
- /* istanbul ignore if */
1017
- if (edition === "proto3") {
1018
- parseField(parent, "proto3_optional", reference, depth + 1);
1019
- } else {
1020
- parseField(parent, "optional", reference, depth + 1);
1021
- }
1022
- break;
1023
-
1024
- default:
1025
- /* istanbul ignore if */
1026
- if (edition === "proto2" || !typeRefRe.test(token))
1027
- throw illegal(token);
1028
- push(token);
1029
- parseField(parent, "optional", reference, depth + 1);
1030
- break;
1031
- }
1032
- });
1033
- }
1034
-
1035
- var token;
1036
- while ((token = next()) !== null) {
1037
- switch (token) {
1038
-
1039
- case ";":
1040
- break;
1041
-
1042
- case "package":
1043
-
1044
- /* istanbul ignore if */
1045
- if (!head)
1046
- throw illegal(token);
1047
-
1048
- parsePackage();
1049
- break;
1050
-
1051
- case "import":
1052
-
1053
- parseImport();
1054
- break;
1055
-
1056
- case "syntax":
1057
-
1058
- /* istanbul ignore if */
1059
- if (!head)
1060
- throw illegal(token);
1061
-
1062
- parseSyntax();
1063
- break;
1064
-
1065
- case "edition":
1066
- /* istanbul ignore if */
1067
- if (!head)
1068
- throw illegal(token);
1069
- parseEdition();
1070
- break;
1071
-
1072
- case "option":
1073
- parseOption(ptr, token);
1074
- skip(";", true);
1075
- break;
1076
-
1077
- default:
1078
-
1079
- /* istanbul ignore else */
1080
- if (parseCommon(ptr, token, 0)) {
1081
- head = false;
1082
- continue;
1083
- }
1084
-
1085
- /* istanbul ignore next */
1086
- throw illegal(token);
1087
- }
1088
- }
1089
-
1090
- resolveFileFeatures();
1091
-
1092
- parse.filename = null;
1093
- return {
1094
- "package" : pkg,
1095
- "imports" : imports,
1096
- weakImports : weakImports,
1097
- root : root
1098
- };
1099
- }
1100
-
1101
- /**
1102
- * Parses the given .proto source and returns an object with the parsed contents.
1103
- * @name parse
1104
- * @function
1105
- * @param {string} source Source contents
1106
- * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
1107
- * @returns {IParserResult} Parser result
1108
- * @property {string} filename=null Currently processing file name for error reporting, if known
1109
- * @property {IParseOptions} defaults Default {@link IParseOptions}
1110
- * @variation 2
1111
- */