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.
- package/benchmark.js +35 -14
- package/bin/tardis-machine.js +0 -1
- package/dist/tardismachine.d.ts.map +1 -1
- package/dist/tardismachine.js +20 -55
- package/dist/tardismachine.js.map +1 -1
- package/dist/ws/replay.d.ts +2 -2
- package/dist/ws/replay.d.ts.map +1 -1
- package/dist/ws/replay.js +11 -5
- package/dist/ws/replay.js.map +1 -1
- package/dist/ws/replaynormalized.d.ts +2 -2
- package/dist/ws/replaynormalized.d.ts.map +1 -1
- package/dist/ws/replaynormalized.js +7 -5
- package/dist/ws/replaynormalized.js.map +1 -1
- package/dist/ws/server.d.ts +20 -0
- package/dist/ws/server.d.ts.map +1 -0
- package/dist/ws/server.js +154 -0
- package/dist/ws/server.js.map +1 -0
- package/dist/ws/streamnormalized.d.ts +2 -2
- package/dist/ws/streamnormalized.d.ts.map +1 -1
- package/dist/ws/streamnormalized.js +7 -5
- package/dist/ws/streamnormalized.js.map +1 -1
- package/dist/ws/subscriptionsmappers.d.ts +1 -1
- package/dist/ws/subscriptionsmappers.d.ts.map +1 -1
- package/node_modules/tardis-dev/README.md +1 -1
- package/node_modules/tardis-dev/dist/debug.d.ts +12 -2
- package/node_modules/tardis-dev/dist/debug.d.ts.map +1 -1
- package/node_modules/tardis-dev/dist/debug.js +2 -1
- package/node_modules/tardis-dev/dist/debug.js.map +1 -1
- package/node_modules/tardis-dev/dist/handy.d.ts +3 -1
- package/node_modules/tardis-dev/dist/handy.d.ts.map +1 -1
- package/node_modules/tardis-dev/dist/handy.js +72 -86
- package/node_modules/tardis-dev/dist/handy.js.map +1 -1
- package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts +0 -7
- package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts.map +1 -1
- package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js +2 -70
- package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js.map +1 -1
- package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts +43 -0
- package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.d.ts.map +1 -0
- package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js +294 -0
- package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js.map +1 -0
- package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts +3 -3
- package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
- package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js +3 -3
- package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js.map +1 -1
- package/node_modules/tardis-dev/dist/worker.js +2 -2
- package/node_modules/tardis-dev/dist/worker.js.map +1 -1
- package/node_modules/tardis-dev/package.json +3 -7
- package/node_modules/tardis-dev/src/debug.ts +16 -1
- package/node_modules/tardis-dev/src/external-modules.d.ts +5 -0
- package/node_modules/tardis-dev/src/handy.ts +93 -89
- package/node_modules/tardis-dev/src/realtimefeeds/mexc.ts +2 -72
- package/node_modules/tardis-dev/src/realtimefeeds/mexcprotobuf.ts +364 -0
- package/node_modules/tardis-dev/src/realtimefeeds/realtimefeed.ts +5 -5
- package/node_modules/tardis-dev/src/worker.ts +2 -2
- package/package.json +8 -34
- package/src/tardismachine.ts +25 -66
- package/src/ws/replay.ts +13 -8
- package/src/ws/replaynormalized.ts +8 -6
- package/src/ws/server.ts +173 -0
- package/src/ws/streamnormalized.ts +8 -6
- package/src/ws/subscriptionsmappers.ts +1 -1
- package/node_modules/follow-redirects/LICENSE +0 -18
- package/node_modules/follow-redirects/README.md +0 -157
- package/node_modules/follow-redirects/debug.js +0 -15
- package/node_modules/follow-redirects/http.js +0 -1
- package/node_modules/follow-redirects/https.js +0 -1
- package/node_modules/follow-redirects/index.js +0 -709
- package/node_modules/follow-redirects/package.json +0 -58
- package/node_modules/long/LICENSE +0 -202
- package/node_modules/long/README.md +0 -286
- package/node_modules/long/index.d.ts +0 -2
- package/node_modules/long/index.js +0 -1581
- package/node_modules/long/package.json +0 -58
- package/node_modules/long/types.d.ts +0 -474
- package/node_modules/long/umd/index.d.ts +0 -3
- package/node_modules/long/umd/index.js +0 -1622
- package/node_modules/long/umd/package.json +0 -3
- package/node_modules/long/umd/types.d.ts +0 -474
- package/node_modules/protobufjs/LICENSE +0 -39
- package/node_modules/protobufjs/README.md +0 -440
- package/node_modules/protobufjs/dist/light/protobuf.js +0 -9276
- package/node_modules/protobufjs/dist/light/protobuf.js.map +0 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +0 -8
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +0 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +0 -3556
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +0 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +0 -8
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +0 -1
- package/node_modules/protobufjs/dist/protobuf.js +0 -11233
- package/node_modules/protobufjs/dist/protobuf.js.map +0 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +0 -8
- package/node_modules/protobufjs/dist/protobuf.min.js.map +0 -1
- package/node_modules/protobufjs/ext/README.md +0 -70
- package/node_modules/protobufjs/ext/debug/README.md +0 -4
- package/node_modules/protobufjs/ext/debug/index.js +0 -71
- package/node_modules/protobufjs/ext/descriptor/README.md +0 -5
- package/node_modules/protobufjs/ext/descriptor/index.d.ts +0 -2
- package/node_modules/protobufjs/ext/descriptor/index.js +0 -2
- package/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
- package/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -417
- package/node_modules/protobufjs/ext/descriptor.js +0 -1356
- package/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
- package/node_modules/protobufjs/ext/protojson.d.ts +0 -20
- package/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
- package/node_modules/protobufjs/ext/protojson.js +0 -951
- package/node_modules/protobufjs/ext/textformat.d.ts +0 -19
- package/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
- package/node_modules/protobufjs/ext/textformat.js +0 -1276
- package/node_modules/protobufjs/google/LICENSE +0 -27
- package/node_modules/protobufjs/google/README.md +0 -1
- package/node_modules/protobufjs/google/api/annotations.json +0 -85
- package/node_modules/protobufjs/google/api/annotations.proto +0 -11
- package/node_modules/protobufjs/google/api/http.json +0 -87
- package/node_modules/protobufjs/google/api/http.proto +0 -31
- package/node_modules/protobufjs/google/protobuf/api.json +0 -124
- package/node_modules/protobufjs/google/protobuf/api.proto +0 -34
- package/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
- package/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
- package/node_modules/protobufjs/google/protobuf/descriptor.json +0 -1465
- package/node_modules/protobufjs/google/protobuf/descriptor.proto +0 -527
- package/node_modules/protobufjs/google/protobuf/source_context.json +0 -21
- package/node_modules/protobufjs/google/protobuf/source_context.proto +0 -7
- package/node_modules/protobufjs/google/protobuf/type.json +0 -209
- package/node_modules/protobufjs/google/protobuf/type.proto +0 -89
- package/node_modules/protobufjs/index.d.ts +0 -3203
- package/node_modules/protobufjs/index.js +0 -4
- package/node_modules/protobufjs/light.d.ts +0 -2
- package/node_modules/protobufjs/light.js +0 -4
- package/node_modules/protobufjs/minimal.d.ts +0 -2
- package/node_modules/protobufjs/minimal.js +0 -4
- package/node_modules/protobufjs/package.json +0 -93
- package/node_modules/protobufjs/src/common.js +0 -405
- package/node_modules/protobufjs/src/converter.js +0 -352
- package/node_modules/protobufjs/src/decoder.js +0 -279
- package/node_modules/protobufjs/src/encoder.js +0 -123
- package/node_modules/protobufjs/src/enum.js +0 -239
- package/node_modules/protobufjs/src/field.js +0 -505
- package/node_modules/protobufjs/src/index-light.js +0 -104
- package/node_modules/protobufjs/src/index-minimal.js +0 -35
- package/node_modules/protobufjs/src/index.js +0 -12
- package/node_modules/protobufjs/src/mapfield.js +0 -144
- package/node_modules/protobufjs/src/message.js +0 -137
- package/node_modules/protobufjs/src/method.js +0 -183
- package/node_modules/protobufjs/src/namespace.js +0 -574
- package/node_modules/protobufjs/src/object.js +0 -392
- package/node_modules/protobufjs/src/oneof.js +0 -233
- package/node_modules/protobufjs/src/parse.js +0 -1111
- package/node_modules/protobufjs/src/reader.js +0 -788
- package/node_modules/protobufjs/src/reader_buffer.js +0 -77
- package/node_modules/protobufjs/src/root.js +0 -424
- package/node_modules/protobufjs/src/roots.js +0 -18
- package/node_modules/protobufjs/src/rpc/service.js +0 -155
- package/node_modules/protobufjs/src/rpc.js +0 -36
- package/node_modules/protobufjs/src/service.js +0 -206
- package/node_modules/protobufjs/src/tokenize.js +0 -421
- package/node_modules/protobufjs/src/type.js +0 -676
- package/node_modules/protobufjs/src/types.js +0 -196
- package/node_modules/protobufjs/src/typescript.js +0 -25
- package/node_modules/protobufjs/src/util/aspromise.d.ts +0 -13
- package/node_modules/protobufjs/src/util/aspromise.js +0 -52
- package/node_modules/protobufjs/src/util/base64.d.ts +0 -32
- package/node_modules/protobufjs/src/util/base64.js +0 -146
- package/node_modules/protobufjs/src/util/codegen.d.ts +0 -31
- package/node_modules/protobufjs/src/util/codegen.js +0 -118
- package/node_modules/protobufjs/src/util/eventemitter.d.ts +0 -45
- package/node_modules/protobufjs/src/util/eventemitter.js +0 -86
- package/node_modules/protobufjs/src/util/fetch.d.ts +0 -56
- package/node_modules/protobufjs/src/util/fetch.js +0 -112
- package/node_modules/protobufjs/src/util/float.d.ts +0 -83
- package/node_modules/protobufjs/src/util/float.js +0 -335
- package/node_modules/protobufjs/src/util/fs.js +0 -11
- package/node_modules/protobufjs/src/util/longbits.js +0 -204
- package/node_modules/protobufjs/src/util/minimal.js +0 -511
- package/node_modules/protobufjs/src/util/path.d.ts +0 -22
- package/node_modules/protobufjs/src/util/path.js +0 -100
- package/node_modules/protobufjs/src/util/patterns.js +0 -7
- package/node_modules/protobufjs/src/util/pool.d.ts +0 -32
- package/node_modules/protobufjs/src/util/pool.js +0 -48
- package/node_modules/protobufjs/src/util/utf8.d.ts +0 -24
- package/node_modules/protobufjs/src/util/utf8.js +0 -190
- package/node_modules/protobufjs/src/util.js +0 -264
- package/node_modules/protobufjs/src/verifier.js +0 -185
- package/node_modules/protobufjs/src/wrappers.js +0 -106
- package/node_modules/protobufjs/src/writer.js +0 -700
- package/node_modules/protobufjs/src/writer_buffer.js +0 -100
- package/node_modules/protobufjs/tsconfig.json +0 -6
- package/node_modules/uWebSockets.js/ESM_wrapper.mjs +0 -53
- package/node_modules/uWebSockets.js/LICENSE +0 -201
- package/node_modules/uWebSockets.js/README.md +0 -6
- package/node_modules/uWebSockets.js/index.d.ts +0 -468
- package/node_modules/uWebSockets.js/package.json +0 -12
- package/node_modules/uWebSockets.js/source_commit +0 -1
- package/node_modules/uWebSockets.js/uws.js +0 -76
- package/node_modules/uWebSockets.js/uws_darwin_arm64_127.node +0 -0
- package/node_modules/uWebSockets.js/uws_darwin_arm64_137.node +0 -0
- package/node_modules/uWebSockets.js/uws_darwin_arm64_147.node +0 -0
- package/node_modules/uWebSockets.js/uws_darwin_x64_127.node +0 -0
- package/node_modules/uWebSockets.js/uws_darwin_x64_137.node +0 -0
- package/node_modules/uWebSockets.js/uws_darwin_x64_147.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_arm64_127.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_arm64_137.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_arm64_147.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_x64_127.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_x64_137.node +0 -0
- package/node_modules/uWebSockets.js/uws_linux_x64_147.node +0 -0
- package/node_modules/uWebSockets.js/uws_win32_x64_127.node +0 -0
- package/node_modules/uWebSockets.js/uws_win32_x64_137.node +0 -0
- package/node_modules/uWebSockets.js/uws_win32_x64_147.node +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
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,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = Service;
|
|
3
|
-
|
|
4
|
-
// extends Namespace
|
|
5
|
-
var Namespace = require("./namespace");
|
|
6
|
-
Service.prototype = Object.create(Namespace.prototype, {
|
|
7
|
-
constructor: {
|
|
8
|
-
value: Service,
|
|
9
|
-
writable: true,
|
|
10
|
-
enumerable: false,
|
|
11
|
-
configurable: true
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Service.className = "Service";
|
|
15
|
-
|
|
16
|
-
var Method = require("./method"),
|
|
17
|
-
util = require("./util"),
|
|
18
|
-
rpc = require("./rpc");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Constructs a new service instance.
|
|
22
|
-
* @classdesc Reflected service.
|
|
23
|
-
* @extends NamespaceBase
|
|
24
|
-
* @constructor
|
|
25
|
-
* @param {string} name Service name
|
|
26
|
-
* @param {Object.<string,*>} [options] Service options
|
|
27
|
-
* @throws {TypeError} If arguments are invalid
|
|
28
|
-
*/
|
|
29
|
-
function Service(name, options) {
|
|
30
|
-
Namespace.call(this, name, options);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Service methods.
|
|
34
|
-
* @type {Object.<string,Method>}
|
|
35
|
-
*/
|
|
36
|
-
this.methods = {}; // toJSON, marker
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Cached methods as an array.
|
|
40
|
-
* @type {Method[]|null}
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
this._methodsArray = null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Service descriptor.
|
|
48
|
-
* @interface IService
|
|
49
|
-
* @extends INamespace
|
|
50
|
-
* @property {string} [edition] Edition
|
|
51
|
-
* @property {Object.<string,IMethod>} methods Method descriptors
|
|
52
|
-
* @property {string|null} [comment] Service comment
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Constructs a service from a service descriptor.
|
|
57
|
-
* @param {string} name Service name
|
|
58
|
-
* @param {IService} json Service descriptor
|
|
59
|
-
* @param {number} [depth] Current nesting depth, defaults to `0`
|
|
60
|
-
* @returns {Service} Created service
|
|
61
|
-
* @throws {TypeError} If arguments are invalid
|
|
62
|
-
*/
|
|
63
|
-
Service.fromJSON = function fromJSON(name, json, depth) {
|
|
64
|
-
if (depth === undefined)
|
|
65
|
-
depth = 0;
|
|
66
|
-
if (depth > util.recursionLimit)
|
|
67
|
-
throw Error("max depth exceeded");
|
|
68
|
-
var service = new Service(name, json.options);
|
|
69
|
-
/* istanbul ignore else */
|
|
70
|
-
if (json.methods)
|
|
71
|
-
for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)
|
|
72
|
-
service.add(Method.fromJSON(names[i], json.methods[names[i]]));
|
|
73
|
-
if (json.nested)
|
|
74
|
-
service.addJSON(json.nested, depth);
|
|
75
|
-
if (json.edition)
|
|
76
|
-
service._edition = json.edition;
|
|
77
|
-
service.comment = json.comment;
|
|
78
|
-
service._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
79
|
-
return service;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Converts this service to a service descriptor.
|
|
84
|
-
* @param {IToJSONOptions} [toJSONOptions] JSON conversion options
|
|
85
|
-
* @returns {IService} Service descriptor
|
|
86
|
-
*/
|
|
87
|
-
Service.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
88
|
-
var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
|
|
89
|
-
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
90
|
-
return util.toObject([
|
|
91
|
-
"edition" , this._editionToJSON(),
|
|
92
|
-
"options" , inherited && inherited.options || undefined,
|
|
93
|
-
"methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},
|
|
94
|
-
"nested" , inherited && inherited.nested || undefined,
|
|
95
|
-
"comment" , keepComments ? this.comment : undefined
|
|
96
|
-
]);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Methods of this service as an array for iteration.
|
|
101
|
-
* @name Service#methodsArray
|
|
102
|
-
* @type {Method[]}
|
|
103
|
-
* @readonly
|
|
104
|
-
*/
|
|
105
|
-
Object.defineProperty(Service.prototype, "methodsArray", {
|
|
106
|
-
get: function() {
|
|
107
|
-
return this._methodsArray || (this._methodsArray = util.toArray(this.methods));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
function clearCache(service) {
|
|
112
|
-
service._methodsArray = null;
|
|
113
|
-
return service;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @override
|
|
118
|
-
*/
|
|
119
|
-
Service.prototype.get = function get(name) {
|
|
120
|
-
return Object.prototype.hasOwnProperty.call(this.methods, name)
|
|
121
|
-
? this.methods[name]
|
|
122
|
-
: Namespace.prototype.get.call(this, name);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @override
|
|
127
|
-
*/
|
|
128
|
-
Service.prototype.resolveAll = function resolveAll() {
|
|
129
|
-
if (!this._needsRecursiveResolve) return this;
|
|
130
|
-
|
|
131
|
-
Namespace.prototype.resolve.call(this);
|
|
132
|
-
var methods = this.methodsArray;
|
|
133
|
-
for (var i = 0; i < methods.length; ++i)
|
|
134
|
-
methods[i].resolve();
|
|
135
|
-
return this;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @override
|
|
140
|
-
*/
|
|
141
|
-
Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
142
|
-
if (!this._needsRecursiveFeatureResolution) return this;
|
|
143
|
-
|
|
144
|
-
edition = this._edition || edition;
|
|
145
|
-
|
|
146
|
-
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
147
|
-
this.methodsArray.forEach(method => {
|
|
148
|
-
method._resolveFeaturesRecursive(edition);
|
|
149
|
-
});
|
|
150
|
-
return this;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @override
|
|
155
|
-
*/
|
|
156
|
-
Service.prototype.add = function add(object) {
|
|
157
|
-
/* istanbul ignore if */
|
|
158
|
-
if (this.get(object.name))
|
|
159
|
-
throw Error("duplicate name '" + object.name + "' in " + this);
|
|
160
|
-
|
|
161
|
-
if (object instanceof Method) {
|
|
162
|
-
if (object.name === "__proto__")
|
|
163
|
-
return this;
|
|
164
|
-
this.methods[object.name] = object;
|
|
165
|
-
object.parent = this;
|
|
166
|
-
return clearCache(this);
|
|
167
|
-
}
|
|
168
|
-
return Namespace.prototype.add.call(this, object);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @override
|
|
173
|
-
*/
|
|
174
|
-
Service.prototype.remove = function remove(object) {
|
|
175
|
-
if (object instanceof Method) {
|
|
176
|
-
|
|
177
|
-
/* istanbul ignore if */
|
|
178
|
-
if (this.methods[object.name] !== object)
|
|
179
|
-
throw Error(object + " is not a member of " + this);
|
|
180
|
-
|
|
181
|
-
delete this.methods[object.name];
|
|
182
|
-
object.parent = null;
|
|
183
|
-
return clearCache(this);
|
|
184
|
-
}
|
|
185
|
-
return Namespace.prototype.remove.call(this, object);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Creates a runtime service using the specified rpc implementation.
|
|
190
|
-
* @param {RPCImpl} rpcImpl RPC implementation
|
|
191
|
-
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
|
|
192
|
-
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
|
|
193
|
-
* @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed.
|
|
194
|
-
*/
|
|
195
|
-
Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) {
|
|
196
|
-
var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited);
|
|
197
|
-
for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) {
|
|
198
|
-
var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, "");
|
|
199
|
-
rpcService[methodName] = (function(method, requestType, responseType) {
|
|
200
|
-
return function rpcMethod(request, callback) {
|
|
201
|
-
return rpc.Service.prototype.rpcCall.call(this, method, requestType, responseType, request, callback);
|
|
202
|
-
};
|
|
203
|
-
})(method, method.resolvedRequestType.ctor, method.resolvedResponseType.ctor);
|
|
204
|
-
}
|
|
205
|
-
return rpcService;
|
|
206
|
-
};
|
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = tokenize;
|
|
3
|
-
|
|
4
|
-
var delimRe = /[\s{}=;:[\],'"()<>]/g,
|
|
5
|
-
stringDoubleRe = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,
|
|
6
|
-
stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g;
|
|
7
|
-
|
|
8
|
-
var setCommentRe = /^ *[*/]+ */,
|
|
9
|
-
setCommentAltRe = /^\s*\*?\/*/,
|
|
10
|
-
setCommentSplitRe = /\n/g,
|
|
11
|
-
whitespaceRe = /\s/,
|
|
12
|
-
unescapeRe = /\\(.?)/g;
|
|
13
|
-
|
|
14
|
-
var unescapeMap = {
|
|
15
|
-
"0": "\0",
|
|
16
|
-
"r": "\r",
|
|
17
|
-
"n": "\n",
|
|
18
|
-
"t": "\t"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Unescapes a string.
|
|
23
|
-
* @param {string} str String to unescape
|
|
24
|
-
* @returns {string} Unescaped string
|
|
25
|
-
* @property {Object.<string,string>} map Special characters map
|
|
26
|
-
* @memberof tokenize
|
|
27
|
-
*/
|
|
28
|
-
function unescape(str) {
|
|
29
|
-
return str.replace(unescapeRe, function($0, $1) {
|
|
30
|
-
switch ($1) {
|
|
31
|
-
case "\\":
|
|
32
|
-
case "":
|
|
33
|
-
return $1;
|
|
34
|
-
default:
|
|
35
|
-
return unescapeMap[$1] || "";
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
tokenize.unescape = unescape;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Gets the next token and advances.
|
|
44
|
-
* @typedef TokenizerHandleNext
|
|
45
|
-
* @type {function}
|
|
46
|
-
* @returns {string|null} Next token or `null` on eof
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Peeks for the next token.
|
|
51
|
-
* @typedef TokenizerHandlePeek
|
|
52
|
-
* @type {function}
|
|
53
|
-
* @returns {string|null} Next token or `null` on eof
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Pushes a token back to the stack.
|
|
58
|
-
* @typedef TokenizerHandlePush
|
|
59
|
-
* @type {function}
|
|
60
|
-
* @param {string} token Token
|
|
61
|
-
* @returns {undefined}
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Skips the next token.
|
|
66
|
-
* @typedef TokenizerHandleSkip
|
|
67
|
-
* @type {function}
|
|
68
|
-
* @param {string} expected Expected token
|
|
69
|
-
* @param {boolean} [optional=false] If optional
|
|
70
|
-
* @returns {boolean} Whether the token matched
|
|
71
|
-
* @throws {Error} If the token didn't match and is not optional
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Gets the comment on the previous line or, alternatively, the line comment on the specified line.
|
|
76
|
-
* @typedef TokenizerHandleCmnt
|
|
77
|
-
* @type {function}
|
|
78
|
-
* @param {number} [line] Line number
|
|
79
|
-
* @returns {string|null} Comment text or `null` if none
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Handle object returned from {@link tokenize}.
|
|
84
|
-
* @interface ITokenizerHandle
|
|
85
|
-
* @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof)
|
|
86
|
-
* @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof)
|
|
87
|
-
* @property {TokenizerHandlePush} push Pushes a token back to the stack
|
|
88
|
-
* @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws
|
|
89
|
-
* @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any
|
|
90
|
-
* @property {number} line Current line number
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Tokenizes the given .proto source and returns an object with useful utility functions.
|
|
95
|
-
* @param {string} source Source contents
|
|
96
|
-
* @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode.
|
|
97
|
-
* @returns {ITokenizerHandle} Tokenizer handle
|
|
98
|
-
*/
|
|
99
|
-
function tokenize(source, alternateCommentMode) {
|
|
100
|
-
/* eslint-disable callback-return */
|
|
101
|
-
source = source.toString();
|
|
102
|
-
|
|
103
|
-
var offset = 0,
|
|
104
|
-
length = source.length,
|
|
105
|
-
line = 1,
|
|
106
|
-
lastCommentLine = 0,
|
|
107
|
-
comments = {};
|
|
108
|
-
|
|
109
|
-
var stack = [];
|
|
110
|
-
|
|
111
|
-
var stringDelim = null;
|
|
112
|
-
|
|
113
|
-
/* istanbul ignore next */
|
|
114
|
-
/**
|
|
115
|
-
* Creates an error for illegal syntax.
|
|
116
|
-
* @param {string} subject Subject
|
|
117
|
-
* @returns {Error} Error created
|
|
118
|
-
* @inner
|
|
119
|
-
*/
|
|
120
|
-
function illegal(subject) {
|
|
121
|
-
return Error("illegal " + subject + " (line " + line + ")");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Reads a string till its end.
|
|
126
|
-
* @returns {string} String read
|
|
127
|
-
* @inner
|
|
128
|
-
*/
|
|
129
|
-
function readString() {
|
|
130
|
-
var re = stringDelim === "'" ? stringSingleRe : stringDoubleRe;
|
|
131
|
-
re.lastIndex = offset - 1;
|
|
132
|
-
var match = re.exec(source);
|
|
133
|
-
if (!match)
|
|
134
|
-
throw illegal("string");
|
|
135
|
-
offset = re.lastIndex;
|
|
136
|
-
push(stringDelim);
|
|
137
|
-
stringDelim = null;
|
|
138
|
-
return unescape(match[1]);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Gets the character at `pos` within the source.
|
|
143
|
-
* @param {number} pos Position
|
|
144
|
-
* @returns {string} Character
|
|
145
|
-
* @inner
|
|
146
|
-
*/
|
|
147
|
-
function charAt(pos) {
|
|
148
|
-
return source.charAt(pos);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Sets the current comment text.
|
|
153
|
-
* @param {number} start Start offset
|
|
154
|
-
* @param {number} end End offset
|
|
155
|
-
* @param {boolean} isLeading set if a leading comment
|
|
156
|
-
* @returns {undefined}
|
|
157
|
-
* @inner
|
|
158
|
-
*/
|
|
159
|
-
function setComment(start, end, isLeading) {
|
|
160
|
-
var comment = {
|
|
161
|
-
type: source.charAt(start++),
|
|
162
|
-
lineEmpty: false,
|
|
163
|
-
leading: isLeading,
|
|
164
|
-
};
|
|
165
|
-
var lookback;
|
|
166
|
-
if (alternateCommentMode) {
|
|
167
|
-
lookback = 2; // alternate comment parsing: "//" or "/*"
|
|
168
|
-
} else {
|
|
169
|
-
lookback = 3; // "///" or "/**"
|
|
170
|
-
}
|
|
171
|
-
var commentOffset = start - lookback,
|
|
172
|
-
c;
|
|
173
|
-
do {
|
|
174
|
-
if (--commentOffset < 0 ||
|
|
175
|
-
(c = source.charAt(commentOffset)) === "\n") {
|
|
176
|
-
comment.lineEmpty = true;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
} while (c === " " || c === "\t");
|
|
180
|
-
var lines = source
|
|
181
|
-
.substring(start, end)
|
|
182
|
-
.split(setCommentSplitRe);
|
|
183
|
-
for (var i = 0; i < lines.length; ++i)
|
|
184
|
-
lines[i] = lines[i]
|
|
185
|
-
.replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "")
|
|
186
|
-
.trim();
|
|
187
|
-
comment.text = lines
|
|
188
|
-
.join("\n")
|
|
189
|
-
.trim();
|
|
190
|
-
|
|
191
|
-
comments[line] = comment;
|
|
192
|
-
lastCommentLine = line;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function isDoubleSlashCommentLine(startOffset) {
|
|
196
|
-
var endOffset = findEndOfLine(startOffset);
|
|
197
|
-
|
|
198
|
-
// see if remaining line matches comment pattern
|
|
199
|
-
var lineText = source.substring(startOffset, endOffset);
|
|
200
|
-
var isComment = /^\s*\/\//.test(lineText);
|
|
201
|
-
return isComment;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function findEndOfLine(cursor) {
|
|
205
|
-
// find end of cursor's line
|
|
206
|
-
var endOffset = cursor;
|
|
207
|
-
while (endOffset < length && charAt(endOffset) !== "\n") {
|
|
208
|
-
endOffset++;
|
|
209
|
-
}
|
|
210
|
-
return endOffset;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Obtains the next token.
|
|
215
|
-
* @returns {string|null} Next token or `null` on eof
|
|
216
|
-
* @inner
|
|
217
|
-
*/
|
|
218
|
-
function next() {
|
|
219
|
-
if (stack.length > 0)
|
|
220
|
-
return stack.shift();
|
|
221
|
-
if (stringDelim)
|
|
222
|
-
return readString();
|
|
223
|
-
var repeat,
|
|
224
|
-
prev,
|
|
225
|
-
curr,
|
|
226
|
-
start,
|
|
227
|
-
isDoc,
|
|
228
|
-
nextLineIsComment,
|
|
229
|
-
isLeadingComment = offset === 0;
|
|
230
|
-
do {
|
|
231
|
-
if (offset === length)
|
|
232
|
-
return null;
|
|
233
|
-
repeat = false;
|
|
234
|
-
while (whitespaceRe.test(curr = charAt(offset))) {
|
|
235
|
-
if (curr === "\n") {
|
|
236
|
-
isLeadingComment = true;
|
|
237
|
-
++line;
|
|
238
|
-
}
|
|
239
|
-
if (++offset === length)
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (charAt(offset) === "/") {
|
|
244
|
-
if (++offset === length) {
|
|
245
|
-
throw illegal("comment");
|
|
246
|
-
}
|
|
247
|
-
if (charAt(offset) === "/") { // Line
|
|
248
|
-
if (!alternateCommentMode) {
|
|
249
|
-
// check for triple-slash comment
|
|
250
|
-
isDoc = charAt(start = offset + 1) === "/";
|
|
251
|
-
|
|
252
|
-
while (charAt(++offset) !== "\n") {
|
|
253
|
-
if (offset === length) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
++offset;
|
|
258
|
-
if (isDoc) {
|
|
259
|
-
setComment(start, offset - 1, isLeadingComment);
|
|
260
|
-
// Trailing comment cannot not be multi-line,
|
|
261
|
-
// so leading comment state should be reset to handle potential next comments
|
|
262
|
-
isLeadingComment = true;
|
|
263
|
-
}
|
|
264
|
-
++line;
|
|
265
|
-
repeat = true;
|
|
266
|
-
} else {
|
|
267
|
-
// check for double-slash comments, consolidating consecutive lines
|
|
268
|
-
start = offset;
|
|
269
|
-
isDoc = false;
|
|
270
|
-
if (isDoubleSlashCommentLine(offset - 1)) {
|
|
271
|
-
isDoc = true;
|
|
272
|
-
do {
|
|
273
|
-
offset = findEndOfLine(offset);
|
|
274
|
-
if (offset === length) {
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
offset++;
|
|
278
|
-
if (!isLeadingComment) {
|
|
279
|
-
// Trailing comment cannot not be multi-line
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
nextLineIsComment = isDoubleSlashCommentLine(offset);
|
|
283
|
-
if (nextLineIsComment) {
|
|
284
|
-
line++;
|
|
285
|
-
}
|
|
286
|
-
} while (nextLineIsComment);
|
|
287
|
-
} else {
|
|
288
|
-
offset = Math.min(length, findEndOfLine(offset) + 1);
|
|
289
|
-
}
|
|
290
|
-
if (isDoc) {
|
|
291
|
-
setComment(start, offset, isLeadingComment);
|
|
292
|
-
isLeadingComment = true;
|
|
293
|
-
}
|
|
294
|
-
line++;
|
|
295
|
-
repeat = true;
|
|
296
|
-
}
|
|
297
|
-
} else if ((curr = charAt(offset)) === "*") { /* Block */
|
|
298
|
-
// check for /** (regular comment mode) or /* (alternate comment mode)
|
|
299
|
-
start = offset + 1;
|
|
300
|
-
isDoc = alternateCommentMode || charAt(start) === "*";
|
|
301
|
-
do {
|
|
302
|
-
if (curr === "\n") {
|
|
303
|
-
++line;
|
|
304
|
-
}
|
|
305
|
-
if (++offset === length) {
|
|
306
|
-
throw illegal("comment");
|
|
307
|
-
}
|
|
308
|
-
prev = curr;
|
|
309
|
-
curr = charAt(offset);
|
|
310
|
-
} while (prev !== "*" || curr !== "/");
|
|
311
|
-
++offset;
|
|
312
|
-
if (isDoc) {
|
|
313
|
-
setComment(start, offset - 2, isLeadingComment);
|
|
314
|
-
isLeadingComment = true;
|
|
315
|
-
}
|
|
316
|
-
repeat = true;
|
|
317
|
-
} else {
|
|
318
|
-
return "/";
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
} while (repeat);
|
|
322
|
-
|
|
323
|
-
// offset !== length if we got here
|
|
324
|
-
|
|
325
|
-
var end = offset;
|
|
326
|
-
delimRe.lastIndex = 0;
|
|
327
|
-
var delim = delimRe.test(charAt(end++));
|
|
328
|
-
if (!delim)
|
|
329
|
-
while (end < length && !delimRe.test(charAt(end)))
|
|
330
|
-
++end;
|
|
331
|
-
var token = source.substring(offset, offset = end);
|
|
332
|
-
if (token === "\"" || token === "'")
|
|
333
|
-
stringDelim = token;
|
|
334
|
-
return token;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Pushes a token back to the stack.
|
|
339
|
-
* @param {string} token Token
|
|
340
|
-
* @returns {undefined}
|
|
341
|
-
* @inner
|
|
342
|
-
*/
|
|
343
|
-
function push(token) {
|
|
344
|
-
stack.push(token);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Peeks for the next token.
|
|
349
|
-
* @returns {string|null} Token or `null` on eof
|
|
350
|
-
* @inner
|
|
351
|
-
*/
|
|
352
|
-
function peek() {
|
|
353
|
-
if (!stack.length) {
|
|
354
|
-
var token = next();
|
|
355
|
-
if (token === null)
|
|
356
|
-
return null;
|
|
357
|
-
push(token);
|
|
358
|
-
}
|
|
359
|
-
return stack[0];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Skips a token.
|
|
364
|
-
* @param {string} expected Expected token
|
|
365
|
-
* @param {boolean} [optional=false] Whether the token is optional
|
|
366
|
-
* @returns {boolean} `true` when skipped, `false` if not
|
|
367
|
-
* @throws {Error} When a required token is not present
|
|
368
|
-
* @inner
|
|
369
|
-
*/
|
|
370
|
-
function skip(expected, optional) {
|
|
371
|
-
var actual = peek(),
|
|
372
|
-
equals = actual === expected;
|
|
373
|
-
if (equals) {
|
|
374
|
-
next();
|
|
375
|
-
return true;
|
|
376
|
-
}
|
|
377
|
-
if (!optional)
|
|
378
|
-
throw illegal("token '" + actual + "', '" + expected + "' expected");
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Gets a comment.
|
|
384
|
-
* @param {number} [trailingLine] Line number if looking for a trailing comment
|
|
385
|
-
* @returns {string|null} Comment text
|
|
386
|
-
* @inner
|
|
387
|
-
*/
|
|
388
|
-
function cmnt(trailingLine) {
|
|
389
|
-
var ret = null;
|
|
390
|
-
var comment;
|
|
391
|
-
if (trailingLine === undefined) {
|
|
392
|
-
comment = comments[line - 1];
|
|
393
|
-
delete comments[line - 1];
|
|
394
|
-
if (comment && (alternateCommentMode || comment.type === "*" || comment.lineEmpty)) {
|
|
395
|
-
ret = comment.leading ? comment.text : null;
|
|
396
|
-
}
|
|
397
|
-
} else {
|
|
398
|
-
/* istanbul ignore else */
|
|
399
|
-
if (lastCommentLine < trailingLine) {
|
|
400
|
-
peek();
|
|
401
|
-
}
|
|
402
|
-
comment = comments[trailingLine];
|
|
403
|
-
delete comments[trailingLine];
|
|
404
|
-
if (comment && !comment.lineEmpty && (alternateCommentMode || comment.type === "/")) {
|
|
405
|
-
ret = comment.leading ? null : comment.text;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return ret;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return Object.defineProperty({
|
|
412
|
-
next: next,
|
|
413
|
-
peek: peek,
|
|
414
|
-
push: push,
|
|
415
|
-
skip: skip,
|
|
416
|
-
cmnt: cmnt
|
|
417
|
-
}, "line", {
|
|
418
|
-
get: function() { return line; }
|
|
419
|
-
});
|
|
420
|
-
/* eslint-enable callback-return */
|
|
421
|
-
}
|