nydus-client 4.0.0 → 4.0.3

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/dist/cjs/index.js CHANGED
@@ -1,225 +1,225 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NydusClient = exports.InvokeError = exports.protocolVersion = void 0;
7
- const engine_io_client_1 = require("engine.io-client");
8
- const cuid_1 = __importDefault(require("cuid"));
9
- const ruta3_1 = __importDefault(require("ruta3"));
10
- const backo2_1 = __importDefault(require("backo2"));
11
- const nydus_protocol_1 = require("nydus-protocol");
12
- Object.defineProperty(exports, "protocolVersion", { enumerable: true, get: function () { return nydus_protocol_1.protocolVersion; } });
13
- const typed_emitter_1 = require("./typed-emitter");
14
- function isTransportError(err) {
15
- return err.type === 'TransportError';
16
- }
17
- class InvokeError extends Error {
18
- constructor(message, status, body) {
19
- super(message);
20
- this.status = status;
21
- this.body = body;
22
- }
23
- }
24
- exports.InvokeError = InvokeError;
25
- class NydusClient extends typed_emitter_1.TypedEventEmitter {
26
- constructor(host, opts = {}) {
27
- super();
28
- this.conn = null;
29
- this.outstanding = new Map();
30
- this.router = (0, ruta3_1.default)();
31
- this.backoffTimer = null;
32
- this.connectTimer = null;
33
- this.wasOpened = false;
34
- this.skipReconnect = false;
35
- this.host = host;
36
- this.opts = opts;
37
- this.opts.reconnectionAttempts = this.opts.reconnectionAttempts || Infinity;
38
- this.backoff = new backo2_1.default({
39
- min: opts.reconnectionDelay || 1000,
40
- max: opts.reconnectionDelayMax || 10000,
41
- jitter: opts.reconnectionJitter || 0.5,
42
- });
43
- }
44
- // One of: opening, open, closing, closed.
45
- get readyState() {
46
- return this.conn != null ? this.conn.readyState : 'closed';
47
- }
48
- doConnect() {
49
- if (this.opts.connectTimeout) {
50
- this.connectTimer = setTimeout(() => {
51
- this.emit('connect_timeout');
52
- this.disconnect();
53
- this.skipReconnect = false;
54
- this.onClose('connect timeout');
55
- }, this.opts.connectTimeout);
56
- }
57
- this.conn = new engine_io_client_1.Socket(this.host, this.opts);
58
- this.conn
59
- .on('open', this.onOpen.bind(this))
60
- .on('message', data => this.onMessage(data))
61
- .on('close', this.onClose.bind(this))
62
- .on('error', this.onError.bind(this));
63
- }
64
- // Connect to the server. If already connected, this will be a no-op.
65
- connect() {
66
- if (this.conn)
67
- return;
68
- this.skipReconnect = false;
69
- this.wasOpened = false;
70
- this.doConnect();
71
- }
72
- reconnect() {
73
- if (this.conn || this.skipReconnect || this.backoffTimer) {
74
- return;
75
- }
76
- if (this.backoff.attempts >= this.opts.reconnectionAttempts) {
77
- this.backoff.reset();
78
- this.emit('reconnect_failed');
79
- return;
80
- }
81
- this.backoffTimer = setTimeout(() => {
82
- this.backoffTimer = null;
83
- this.emit('reconnecting', this.backoff.attempts);
84
- if (this.skipReconnect || this.conn)
85
- return;
86
- this.doConnect();
87
- }, this.backoff.duration());
88
- }
89
- // Disconnect from the server. If not already connected, this will be a no-op.
90
- disconnect() {
91
- this.skipReconnect = true;
92
- if (this.backoffTimer) {
93
- clearTimeout(this.backoffTimer);
94
- this.backoffTimer = null;
95
- }
96
- if (!this.conn)
97
- return;
98
- this.conn.close();
99
- }
100
- /**
101
- * Registers a handler function to respond to PUBLISHes to paths matching a specified pattern.
102
- * Handlers are normal functions of the form:
103
- * `function({ route, params, splats }, data)`
104
- *
105
- * PUBLISHes that don't match a route will be emitted as an 'unhandled' event on this object,
106
- * which can be useful to track in development mode.
107
- */
108
- registerRoute(pathPattern, handler) {
109
- this.router.addRoute(pathPattern, handler);
110
- }
111
- onPublish({ path, data }) {
112
- const route = this.router.match(path);
113
- if (!route) {
114
- this.emit('unhandled', { path, data });
115
- return;
116
- }
117
- route.action({ route: route.route, params: route.params, splats: route.splats }, data);
118
- }
119
- /**
120
- * Invoke a remote method on the server, specified via a path. Optionally, data can be specified
121
- * to send along with the call (will be JSON encoded). A Promise will be returned, resolved or
122
- * rejected with the result or error (respectively) from the server.
123
- */
124
- invoke(path, data) {
125
- const id = (0, cuid_1.default)();
126
- const p = new Promise((resolve, reject) => {
127
- if (!this.conn) {
128
- reject(new Error('Not connected'));
129
- return;
130
- }
131
- this.outstanding.set(id, { resolve, reject });
132
- this.conn.send((0, nydus_protocol_1.encode)(nydus_protocol_1.MessageType.Invoke, data, id, path), undefined);
133
- }).catch(err => {
134
- // Convert error-like objects back to Errors
135
- if (err.message && err.status) {
136
- const converted = new InvokeError(err.message, err.status, err.body);
137
- throw converted;
138
- }
139
- throw err;
140
- });
141
- p.finally(() => this.outstanding.delete(id));
142
- return p;
143
- }
144
- onInvokeResponse({ type, id, data }) {
145
- const p = this.outstanding.get(id);
146
- if (!p) {
147
- this.emit('error', new Error('Unknown invoke id'));
148
- return;
149
- }
150
- p[type === nydus_protocol_1.MessageType.Result ? 'resolve' : 'reject'](data);
151
- }
152
- onOpen() {
153
- this.clearConnectTimer();
154
- this.wasOpened = true;
155
- this.backoff.reset();
156
- this.emit('connect');
157
- }
158
- onMessage(msg) {
159
- var _a, _b;
160
- const decoded = (0, nydus_protocol_1.decode)(msg);
161
- switch (decoded.type) {
162
- case nydus_protocol_1.MessageType.ParserError:
163
- (_a = this.conn) === null || _a === void 0 ? void 0 : _a.close(); // will cause a call to _onClose
164
- break;
165
- case nydus_protocol_1.MessageType.Welcome:
166
- if (decoded.data !== nydus_protocol_1.protocolVersion) {
167
- this.emit('error', new Error('Server has incompatible protocol version: ' + nydus_protocol_1.protocolVersion));
168
- (_b = this.conn) === null || _b === void 0 ? void 0 : _b.close();
169
- }
170
- break;
171
- case nydus_protocol_1.MessageType.Result:
172
- case nydus_protocol_1.MessageType.Error:
173
- this.onInvokeResponse(decoded);
174
- break;
175
- case nydus_protocol_1.MessageType.Publish:
176
- this.onPublish(decoded);
177
- break;
178
- }
179
- }
180
- onClose(reason, details) {
181
- this.clearConnectTimer();
182
- this.conn = null;
183
- if (!this.wasOpened) {
184
- this.emit('connect_failed');
185
- this.reconnect();
186
- // Sockets can emit 'close' even if the connection was never actually opened. Don't emit emits
187
- // upstream in that case, since they're rather unnecessary
188
- return;
189
- }
190
- this.emit('disconnect', reason, details);
191
- this.outstanding.clear();
192
- this.wasOpened = false;
193
- this.reconnect();
194
- }
195
- onError(err) {
196
- this.clearConnectTimer();
197
- if (isTransportError(err) && err.message === 'xhr poll error') {
198
- this.onClose('error', err);
199
- return;
200
- }
201
- if (this.skipReconnect &&
202
- isTransportError(err) &&
203
- err.description &&
204
- err.description.message &&
205
- err.description.message.includes('closed before the connection was established')) {
206
- // ws sometimes throws errors if you disconnect a socket that was in the process of
207
- // reconnecting. Since the disconnect was requested (_skipReconnect is true), this seems
208
- // spurious, so we just ignore it
209
- return;
210
- }
211
- this.emit('error', err);
212
- }
213
- clearConnectTimer() {
214
- if (this.connectTimer) {
215
- clearTimeout(this.connectTimer);
216
- this.connectTimer = null;
217
- }
218
- }
219
- }
220
- exports.NydusClient = NydusClient;
221
- function createClient(host, opts) {
222
- return new NydusClient(host, opts);
223
- }
224
- exports.default = createClient;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NydusClient = exports.InvokeError = exports.protocolVersion = void 0;
7
+ exports.default = createClient;
8
+ const engine_io_client_1 = require("engine.io-client");
9
+ const cuid_1 = __importDefault(require("cuid"));
10
+ const ruta3_1 = __importDefault(require("ruta3"));
11
+ const backo2_1 = __importDefault(require("backo2"));
12
+ const nydus_protocol_1 = require("nydus-protocol");
13
+ Object.defineProperty(exports, "protocolVersion", { enumerable: true, get: function () { return nydus_protocol_1.protocolVersion; } });
14
+ const typed_emitter_1 = require("./typed-emitter");
15
+ function isTransportError(err) {
16
+ return err.type === 'TransportError';
17
+ }
18
+ class InvokeError extends Error {
19
+ constructor(message, status, body) {
20
+ super(message);
21
+ this.status = status;
22
+ this.body = body;
23
+ }
24
+ }
25
+ exports.InvokeError = InvokeError;
26
+ class NydusClient extends typed_emitter_1.TypedEventEmitter {
27
+ constructor(host, opts = {}) {
28
+ super();
29
+ this.conn = null;
30
+ this.outstanding = new Map();
31
+ this.router = (0, ruta3_1.default)();
32
+ this.backoffTimer = null;
33
+ this.connectTimer = null;
34
+ this.wasOpened = false;
35
+ this.skipReconnect = false;
36
+ this.host = host;
37
+ this.opts = opts;
38
+ this.opts.reconnectionAttempts = this.opts.reconnectionAttempts || Infinity;
39
+ this.backoff = new backo2_1.default({
40
+ min: opts.reconnectionDelay || 1000,
41
+ max: opts.reconnectionDelayMax || 10000,
42
+ jitter: opts.reconnectionJitter || 0.5,
43
+ });
44
+ }
45
+ // One of: opening, open, closing, closed.
46
+ get readyState() {
47
+ return this.conn != null ? this.conn.readyState : 'closed';
48
+ }
49
+ doConnect() {
50
+ if (this.opts.connectTimeout) {
51
+ this.connectTimer = setTimeout(() => {
52
+ this.emit('connect_timeout');
53
+ this.disconnect();
54
+ this.skipReconnect = false;
55
+ this.onClose('connect timeout');
56
+ }, this.opts.connectTimeout);
57
+ }
58
+ this.conn = new engine_io_client_1.Socket(this.host, this.opts);
59
+ this.conn
60
+ .on('open', this.onOpen.bind(this))
61
+ .on('message', data => this.onMessage(data))
62
+ .on('close', this.onClose.bind(this))
63
+ .on('error', this.onError.bind(this));
64
+ }
65
+ // Connect to the server. If already connected, this will be a no-op.
66
+ connect() {
67
+ if (this.conn)
68
+ return;
69
+ this.skipReconnect = false;
70
+ this.wasOpened = false;
71
+ this.doConnect();
72
+ }
73
+ reconnect() {
74
+ if (this.conn || this.skipReconnect || this.backoffTimer) {
75
+ return;
76
+ }
77
+ if (this.backoff.attempts >= this.opts.reconnectionAttempts) {
78
+ this.backoff.reset();
79
+ this.emit('reconnect_failed');
80
+ return;
81
+ }
82
+ this.backoffTimer = setTimeout(() => {
83
+ this.backoffTimer = null;
84
+ this.emit('reconnecting', this.backoff.attempts);
85
+ if (this.skipReconnect || this.conn)
86
+ return;
87
+ this.doConnect();
88
+ }, this.backoff.duration());
89
+ }
90
+ // Disconnect from the server. If not already connected, this will be a no-op.
91
+ disconnect() {
92
+ this.skipReconnect = true;
93
+ if (this.backoffTimer) {
94
+ clearTimeout(this.backoffTimer);
95
+ this.backoffTimer = null;
96
+ }
97
+ if (!this.conn)
98
+ return;
99
+ this.conn.close();
100
+ }
101
+ /**
102
+ * Registers a handler function to respond to PUBLISHes to paths matching a specified pattern.
103
+ * Handlers are normal functions of the form:
104
+ * `function({ route, params, splats }, data)`
105
+ *
106
+ * PUBLISHes that don't match a route will be emitted as an 'unhandled' event on this object,
107
+ * which can be useful to track in development mode.
108
+ */
109
+ registerRoute(pathPattern, handler) {
110
+ this.router.addRoute(pathPattern, handler);
111
+ }
112
+ onPublish({ path, data }) {
113
+ const route = this.router.match(path);
114
+ if (!route) {
115
+ this.emit('unhandled', { path, data });
116
+ return;
117
+ }
118
+ route.action({ route: route.route, params: route.params, splats: route.splats }, data);
119
+ }
120
+ /**
121
+ * Invoke a remote method on the server, specified via a path. Optionally, data can be specified
122
+ * to send along with the call (will be JSON encoded). A Promise will be returned, resolved or
123
+ * rejected with the result or error (respectively) from the server.
124
+ */
125
+ invoke(path, data) {
126
+ const id = (0, cuid_1.default)();
127
+ return new Promise((resolve, reject) => {
128
+ if (!this.conn) {
129
+ reject(new Error('Not connected'));
130
+ return;
131
+ }
132
+ this.outstanding.set(id, { resolve, reject });
133
+ this.conn.send((0, nydus_protocol_1.encode)(nydus_protocol_1.MessageType.Invoke, data, id, path), undefined);
134
+ })
135
+ .catch(err => {
136
+ // Convert error-like objects back to Errors
137
+ if (err.message && err.status) {
138
+ const converted = new InvokeError(err.message, err.status, err.body);
139
+ throw converted;
140
+ }
141
+ throw err;
142
+ })
143
+ .finally(() => this.outstanding.delete(id));
144
+ }
145
+ onInvokeResponse({ type, id, data }) {
146
+ const p = this.outstanding.get(id);
147
+ if (!p) {
148
+ this.emit('error', new Error('Unknown invoke id'));
149
+ return;
150
+ }
151
+ p[type === nydus_protocol_1.MessageType.Result ? 'resolve' : 'reject'](data);
152
+ }
153
+ onOpen() {
154
+ this.clearConnectTimer();
155
+ this.wasOpened = true;
156
+ this.backoff.reset();
157
+ this.emit('connect');
158
+ }
159
+ onMessage(msg) {
160
+ var _a, _b;
161
+ const decoded = (0, nydus_protocol_1.decode)(msg);
162
+ switch (decoded.type) {
163
+ case nydus_protocol_1.MessageType.ParserError:
164
+ (_a = this.conn) === null || _a === void 0 ? void 0 : _a.close(); // will cause a call to _onClose
165
+ break;
166
+ case nydus_protocol_1.MessageType.Welcome:
167
+ if (decoded.data !== nydus_protocol_1.protocolVersion) {
168
+ this.emit('error', new Error('Server has incompatible protocol version: ' + nydus_protocol_1.protocolVersion));
169
+ (_b = this.conn) === null || _b === void 0 ? void 0 : _b.close();
170
+ }
171
+ break;
172
+ case nydus_protocol_1.MessageType.Result:
173
+ case nydus_protocol_1.MessageType.Error:
174
+ this.onInvokeResponse(decoded);
175
+ break;
176
+ case nydus_protocol_1.MessageType.Publish:
177
+ this.onPublish(decoded);
178
+ break;
179
+ }
180
+ }
181
+ onClose(reason, details) {
182
+ this.clearConnectTimer();
183
+ this.conn = null;
184
+ if (!this.wasOpened) {
185
+ this.emit('connect_failed');
186
+ this.reconnect();
187
+ // Sockets can emit 'close' even if the connection was never actually opened. Don't emit emits
188
+ // upstream in that case, since they're rather unnecessary
189
+ return;
190
+ }
191
+ this.emit('disconnect', reason, details);
192
+ this.outstanding.clear();
193
+ this.wasOpened = false;
194
+ this.reconnect();
195
+ }
196
+ onError(err) {
197
+ this.clearConnectTimer();
198
+ if (isTransportError(err) && err.message === 'xhr poll error') {
199
+ this.onClose('error', err);
200
+ return;
201
+ }
202
+ if (this.skipReconnect &&
203
+ isTransportError(err) &&
204
+ err.description &&
205
+ err.description.message &&
206
+ err.description.message.includes('closed before the connection was established')) {
207
+ // ws sometimes throws errors if you disconnect a socket that was in the process of
208
+ // reconnecting. Since the disconnect was requested (_skipReconnect is true), this seems
209
+ // spurious, so we just ignore it
210
+ return;
211
+ }
212
+ this.emit('error', err);
213
+ }
214
+ clearConnectTimer() {
215
+ if (this.connectTimer) {
216
+ clearTimeout(this.connectTimer);
217
+ this.connectTimer = null;
218
+ }
219
+ }
220
+ }
221
+ exports.NydusClient = NydusClient;
222
+ function createClient(host, opts) {
223
+ return new NydusClient(host, opts);
224
+ }
225
225
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAmG;AACnG,gDAAuB;AACvB,kDAAwB;AACxB,oDAA4B;AAC5B,mDAQuB;AAGd,gGARP,gCAAe,OAQO;AAFxB,mDAA6D;AAqC7D,SAAS,gBAAgB,CAAC,GAAU;IAClC,OAAQ,GAAW,CAAC,IAAI,KAAK,gBAAgB,CAAA;AAC/C,CAAC;AAiCD,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAY,OAAe,EAAE,MAAc,EAAE,IAAU;QACrD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AATD,kCASC;AAID,MAAa,WAAY,SAAQ,iCAA8B;IAe7D,YAAY,IAAY,EAAE,OAAoC,EAAE;QAC9D,KAAK,EAAE,CAAA;QAbT,SAAI,GAA0B,IAAI,CAAA;QAE1B,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAA;QAClD,WAAM,GAAG,IAAA,eAAI,GAAgB,CAAA;QAG7B,iBAAY,GAAyC,IAAI,CAAA;QACzD,iBAAY,GAAyC,IAAI,CAAA;QAEzD,cAAS,GAAG,KAAK,CAAA;QACjB,kBAAa,GAAG,KAAK,CAAA;QAI3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IA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AE,IAAI,CAAC,CAAA;AACpC,CAAC"}
@@ -1,39 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypedEventEmitter = void 0;
4
- const events_1 = require("events");
5
- /**
6
- * A typed version of the normal node EventEmitter class, such that emitted/handled events and
7
- * their associated parameters can be type-checked properly.
8
- *
9
- * This uses typed-emitter under the hood, it just makes it easier to extend.
10
- *
11
- * Example:
12
- * ```
13
- * interface FooEvents {
14
- * bar: (message: string) => void
15
- * baz: (count: number, ...extras: any[]) => void
16
- * }
17
- *
18
- * class Foo extends TypedEventEmitter<FooEvents> {
19
- * constructor() {
20
- * super()
21
- * }
22
- *
23
- * test() {
24
- * this.emit('bar', 'hello world')
25
- * this.emit('baz', 5, 'extra', 'stuff', 'to', 'pass', 27)
26
- * }
27
- * }
28
- * ```
29
- */
30
- class TypedEventEmitter extends events_1.EventEmitter {
31
- constructor() {
32
- // NOTE(tec27): No idea why eslint thinks super isn't a constructor here, I assume it's failing
33
- // to parse things properly in some way
34
- // eslint-disable-next-line constructor-super
35
- super();
36
- }
37
- }
38
- exports.TypedEventEmitter = TypedEventEmitter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypedEventEmitter = void 0;
4
+ const events_1 = require("events");
5
+ /**
6
+ * A typed version of the normal node EventEmitter class, such that emitted/handled events and
7
+ * their associated parameters can be type-checked properly.
8
+ *
9
+ * This uses typed-emitter under the hood, it just makes it easier to extend.
10
+ *
11
+ * Example:
12
+ * ```
13
+ * interface FooEvents {
14
+ * bar: (message: string) => void
15
+ * baz: (count: number, ...extras: any[]) => void
16
+ * }
17
+ *
18
+ * class Foo extends TypedEventEmitter<FooEvents> {
19
+ * constructor() {
20
+ * super()
21
+ * }
22
+ *
23
+ * test() {
24
+ * this.emit('bar', 'hello world')
25
+ * this.emit('baz', 5, 'extra', 'stuff', 'to', 'pass', 27)
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ class TypedEventEmitter extends events_1.EventEmitter {
31
+ constructor() {
32
+ // NOTE(tec27): No idea why eslint thinks super isn't a constructor here, I assume it's failing
33
+ // to parse things properly in some way
34
+ // eslint-disable-next-line constructor-super
35
+ super();
36
+ }
37
+ }
38
+ exports.TypedEventEmitter = TypedEventEmitter;
39
39
  //# sourceMappingURL=typed-emitter.js.map