@orangelogic/design-system 2.62.0-pr83324.2 → 2.62.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.
- package/library/chunks/{hub-connection.CfARlehM.js → hub-connection.BxT2b7Nq.js} +287 -333
- package/library/components/atoms.js +1 -1
- package/library/components/hub-connection.js +1 -1
- package/library/components/types.js +2 -2
- package/library/package.json +1 -1
- package/library/packages/atoms/src/components/hub-connection/hub-connection.d.ts +0 -17
- package/library/packages/events/src/events.d.ts +3 -6
- package/library/react-web-component.d.ts +0 -4
- package/package.json +1 -1
- package/library/packages/events/src/cx-hub-connection-disconnected.d.ts +0 -8
- package/library/packages/events/src/cx-hub-connection-reconnected.d.ts +0 -8
- package/library/packages/events/src/cx-hub-connection-reconnecting.d.ts +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as K, n as
|
|
1
|
+
import { C as K, n as T } from "./lib-cortex-element.CVMmyPMC.js";
|
|
2
2
|
import { c as X } from "./custom-element.L4WJXn1j.js";
|
|
3
3
|
import { w as J } from "./watch.q1sEjPWL.js";
|
|
4
4
|
import { r as F } from "./state.CSDxrqLd.js";
|
|
5
|
-
class
|
|
5
|
+
class v extends Error {
|
|
6
6
|
/** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
|
|
7
7
|
*
|
|
8
8
|
* @param {string} errorMessage A descriptive error message.
|
|
@@ -23,7 +23,7 @@ class M extends Error {
|
|
|
23
23
|
super(e), this.__proto__ = t;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class b extends Error {
|
|
27
27
|
/** Constructs a new instance of {@link AbortError}.
|
|
28
28
|
*
|
|
29
29
|
* @param {string} errorMessage A descriptive error message.
|
|
@@ -124,10 +124,10 @@ class x {
|
|
|
124
124
|
return "";
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
var
|
|
127
|
+
var i;
|
|
128
128
|
(function(s) {
|
|
129
129
|
s[s.Trace = 0] = "Trace", s[s.Debug = 1] = "Debug", s[s.Information = 2] = "Information", s[s.Warning = 3] = "Warning", s[s.Error = 4] = "Error", s[s.Critical = 5] = "Critical", s[s.None = 6] = "None";
|
|
130
|
-
})(
|
|
130
|
+
})(i || (i = {}));
|
|
131
131
|
class P {
|
|
132
132
|
constructor() {
|
|
133
133
|
}
|
|
@@ -173,7 +173,7 @@ class _ {
|
|
|
173
173
|
}
|
|
174
174
|
function R(s, e) {
|
|
175
175
|
let t = "";
|
|
176
|
-
return
|
|
176
|
+
return E(s) ? (t = `Binary data of length ${s.byteLength}`, e && (t += `. Content: '${ee(s)}'`)) : typeof s == "string" && (t = `String data of length ${s.length}`, e && (t += `. Content: '${s}'`)), t;
|
|
177
177
|
}
|
|
178
178
|
function ee(s) {
|
|
179
179
|
const e = new Uint8Array(s);
|
|
@@ -183,24 +183,24 @@ function ee(s) {
|
|
|
183
183
|
t += `0x${o}${n.toString(16)} `;
|
|
184
184
|
}), t.substr(0, t.length - 1);
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function E(s) {
|
|
187
187
|
return s && typeof ArrayBuffer < "u" && (s instanceof ArrayBuffer || // Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
|
|
188
188
|
s.constructor && s.constructor.name === "ArrayBuffer");
|
|
189
189
|
}
|
|
190
|
-
async function z(s, e, t, n, o,
|
|
191
|
-
const c = {}, [a, l] =
|
|
192
|
-
c[a] = l, s.log(
|
|
193
|
-
const u =
|
|
190
|
+
async function z(s, e, t, n, o, r) {
|
|
191
|
+
const c = {}, [a, l] = I();
|
|
192
|
+
c[a] = l, s.log(i.Trace, `(${e} transport) sending data. ${R(o, r.logMessageContent)}.`);
|
|
193
|
+
const u = E(o) ? "arraybuffer" : "text", d = await t.post(n, {
|
|
194
194
|
content: o,
|
|
195
|
-
headers: { ...c, ...
|
|
195
|
+
headers: { ...c, ...r.headers },
|
|
196
196
|
responseType: u,
|
|
197
|
-
timeout:
|
|
198
|
-
withCredentials:
|
|
197
|
+
timeout: r.timeout,
|
|
198
|
+
withCredentials: r.withCredentials
|
|
199
199
|
});
|
|
200
|
-
s.log(
|
|
200
|
+
s.log(i.Trace, `(${e} transport) request complete. Response status: ${d.statusCode}.`);
|
|
201
201
|
}
|
|
202
202
|
function te(s) {
|
|
203
|
-
return s === void 0 ? new D(
|
|
203
|
+
return s === void 0 ? new D(i.Information) : s === null ? P.instance : s.log !== void 0 ? s : new D(s);
|
|
204
204
|
}
|
|
205
205
|
class ne {
|
|
206
206
|
constructor(e, t) {
|
|
@@ -218,16 +218,16 @@ class D {
|
|
|
218
218
|
}
|
|
219
219
|
log(e, t) {
|
|
220
220
|
if (e >= this._minLevel) {
|
|
221
|
-
const n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${
|
|
221
|
+
const n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${i[e]}: ${t}`;
|
|
222
222
|
switch (e) {
|
|
223
|
-
case
|
|
224
|
-
case
|
|
223
|
+
case i.Critical:
|
|
224
|
+
case i.Error:
|
|
225
225
|
this.out.error(n);
|
|
226
226
|
break;
|
|
227
|
-
case
|
|
227
|
+
case i.Warning:
|
|
228
228
|
this.out.warn(n);
|
|
229
229
|
break;
|
|
230
|
-
case
|
|
230
|
+
case i.Information:
|
|
231
231
|
this.out.info(n);
|
|
232
232
|
break;
|
|
233
233
|
default:
|
|
@@ -237,14 +237,14 @@ class D {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function I() {
|
|
241
241
|
let s = "X-SignalR-User-Agent";
|
|
242
|
-
return _.isNode && (s = "User-Agent"), [s, oe(Z, se(),
|
|
242
|
+
return _.isNode && (s = "User-Agent"), [s, oe(Z, se(), ie(), re())];
|
|
243
243
|
}
|
|
244
244
|
function oe(s, e, t, n) {
|
|
245
245
|
let o = "Microsoft SignalR/";
|
|
246
|
-
const
|
|
247
|
-
return o += `${
|
|
246
|
+
const r = s.split(".");
|
|
247
|
+
return o += `${r[0]}.${r[1]}`, o += ` (${s}; `, e && e !== "" ? o += `${e}; ` : o += "Unknown OS; ", o += `${t}`, n ? o += `; ${n}` : o += "; Unknown Runtime Version", o += ")", o;
|
|
248
248
|
}
|
|
249
249
|
function se() {
|
|
250
250
|
if (_.isNode)
|
|
@@ -261,11 +261,11 @@ function se() {
|
|
|
261
261
|
else
|
|
262
262
|
return "";
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function re() {
|
|
265
265
|
if (_.isNode)
|
|
266
266
|
return process.versions.node;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function ie() {
|
|
269
269
|
return _.isNode ? "NodeJS" : "Browser";
|
|
270
270
|
}
|
|
271
271
|
function A(s) {
|
|
@@ -298,7 +298,7 @@ class ae extends x {
|
|
|
298
298
|
/** @inheritDoc */
|
|
299
299
|
async send(e) {
|
|
300
300
|
if (e.abortSignal && e.abortSignal.aborted)
|
|
301
|
-
throw new
|
|
301
|
+
throw new b();
|
|
302
302
|
if (!e.method)
|
|
303
303
|
throw new Error("No method defined.");
|
|
304
304
|
if (!e.url)
|
|
@@ -306,19 +306,19 @@ class ae extends x {
|
|
|
306
306
|
const t = new this._abortControllerType();
|
|
307
307
|
let n;
|
|
308
308
|
e.abortSignal && (e.abortSignal.onabort = () => {
|
|
309
|
-
t.abort(), n = new
|
|
309
|
+
t.abort(), n = new b();
|
|
310
310
|
});
|
|
311
311
|
let o = null;
|
|
312
312
|
if (e.timeout) {
|
|
313
313
|
const l = e.timeout;
|
|
314
314
|
o = setTimeout(() => {
|
|
315
|
-
t.abort(), this._logger.log(
|
|
315
|
+
t.abort(), this._logger.log(i.Warning, "Timeout from HTTP request."), n = new M();
|
|
316
316
|
}, l);
|
|
317
317
|
}
|
|
318
|
-
e.content === "" && (e.content = void 0), e.content && (e.headers = e.headers || {},
|
|
319
|
-
let
|
|
318
|
+
e.content === "" && (e.content = void 0), e.content && (e.headers = e.headers || {}, E(e.content) ? e.headers["Content-Type"] = "application/octet-stream" : e.headers["Content-Type"] = "text/plain;charset=UTF-8");
|
|
319
|
+
let r;
|
|
320
320
|
try {
|
|
321
|
-
|
|
321
|
+
r = await this._fetchType(e.url, {
|
|
322
322
|
body: e.content,
|
|
323
323
|
cache: "no-cache",
|
|
324
324
|
credentials: e.withCredentials === !0 ? "include" : "same-origin",
|
|
@@ -332,23 +332,23 @@ class ae extends x {
|
|
|
332
332
|
signal: t.signal
|
|
333
333
|
});
|
|
334
334
|
} catch (l) {
|
|
335
|
-
throw n || (this._logger.log(
|
|
335
|
+
throw n || (this._logger.log(i.Warning, `Error from HTTP request. ${l}.`), l);
|
|
336
336
|
} finally {
|
|
337
337
|
o && clearTimeout(o), e.abortSignal && (e.abortSignal.onabort = null);
|
|
338
338
|
}
|
|
339
|
-
if (!
|
|
340
|
-
const l = await
|
|
341
|
-
throw new
|
|
339
|
+
if (!r.ok) {
|
|
340
|
+
const l = await B(r, "text");
|
|
341
|
+
throw new v(l || r.statusText, r.status);
|
|
342
342
|
}
|
|
343
|
-
const a = await
|
|
344
|
-
return new q(
|
|
343
|
+
const a = await B(r, e.responseType);
|
|
344
|
+
return new q(r.status, r.statusText, a);
|
|
345
345
|
}
|
|
346
346
|
getCookieString(e) {
|
|
347
347
|
let t = "";
|
|
348
348
|
return _.isNode && this._jar && this._jar.getCookies(e, (n, o) => t = o.join("; ")), t;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function B(s, e) {
|
|
352
352
|
let t;
|
|
353
353
|
switch (e) {
|
|
354
354
|
case "arraybuffer":
|
|
@@ -373,20 +373,20 @@ class le extends x {
|
|
|
373
373
|
}
|
|
374
374
|
/** @inheritDoc */
|
|
375
375
|
send(e) {
|
|
376
|
-
return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new
|
|
376
|
+
return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new b()) : e.method ? e.url ? new Promise((t, n) => {
|
|
377
377
|
const o = new XMLHttpRequest();
|
|
378
|
-
o.open(e.method, e.url, !0), o.withCredentials = e.withCredentials === void 0 ? !0 : e.withCredentials, o.setRequestHeader("X-Requested-With", "XMLHttpRequest"), e.content === "" && (e.content = void 0), e.content && (
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
o.setRequestHeader(c,
|
|
378
|
+
o.open(e.method, e.url, !0), o.withCredentials = e.withCredentials === void 0 ? !0 : e.withCredentials, o.setRequestHeader("X-Requested-With", "XMLHttpRequest"), e.content === "" && (e.content = void 0), e.content && (E(e.content) ? o.setRequestHeader("Content-Type", "application/octet-stream") : o.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"));
|
|
379
|
+
const r = e.headers;
|
|
380
|
+
r && Object.keys(r).forEach((c) => {
|
|
381
|
+
o.setRequestHeader(c, r[c]);
|
|
382
382
|
}), e.responseType && (o.responseType = e.responseType), e.abortSignal && (e.abortSignal.onabort = () => {
|
|
383
|
-
o.abort(), n(new
|
|
383
|
+
o.abort(), n(new b());
|
|
384
384
|
}), e.timeout && (o.timeout = e.timeout), o.onload = () => {
|
|
385
|
-
e.abortSignal && (e.abortSignal.onabort = null), o.status >= 200 && o.status < 300 ? t(new q(o.status, o.statusText, o.response || o.responseText)) : n(new
|
|
385
|
+
e.abortSignal && (e.abortSignal.onabort = null), o.status >= 200 && o.status < 300 ? t(new q(o.status, o.statusText, o.response || o.responseText)) : n(new v(o.response || o.responseText || o.statusText, o.status));
|
|
386
386
|
}, o.onerror = () => {
|
|
387
|
-
this._logger.log(
|
|
387
|
+
this._logger.log(i.Warning, `Error from HTTP request. ${o.status}: ${o.statusText}.`), n(new v(o.statusText, o.status));
|
|
388
388
|
}, o.ontimeout = () => {
|
|
389
|
-
this._logger.log(
|
|
389
|
+
this._logger.log(i.Warning, "Timeout from HTTP request."), n(new M());
|
|
390
390
|
}, o.send(e.content);
|
|
391
391
|
}) : Promise.reject(new Error("No url defined.")) : Promise.reject(new Error("No method defined."));
|
|
392
392
|
}
|
|
@@ -403,49 +403,49 @@ class he extends x {
|
|
|
403
403
|
}
|
|
404
404
|
/** @inheritDoc */
|
|
405
405
|
send(e) {
|
|
406
|
-
return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new
|
|
406
|
+
return e.abortSignal && e.abortSignal.aborted ? Promise.reject(new b()) : e.method ? e.url ? this._httpClient.send(e) : Promise.reject(new Error("No url defined.")) : Promise.reject(new Error("No method defined."));
|
|
407
407
|
}
|
|
408
408
|
getCookieString(e) {
|
|
409
409
|
return this._httpClient.getCookieString(e);
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
class
|
|
412
|
+
class w {
|
|
413
413
|
static write(e) {
|
|
414
|
-
return `${e}${
|
|
414
|
+
return `${e}${w.RecordSeparator}`;
|
|
415
415
|
}
|
|
416
416
|
static parse(e) {
|
|
417
|
-
if (e[e.length - 1] !==
|
|
417
|
+
if (e[e.length - 1] !== w.RecordSeparator)
|
|
418
418
|
throw new Error("Message is incomplete.");
|
|
419
|
-
const t = e.split(
|
|
419
|
+
const t = e.split(w.RecordSeparator);
|
|
420
420
|
return t.pop(), t;
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
w.RecordSeparatorCode = 30;
|
|
424
|
+
w.RecordSeparator = String.fromCharCode(w.RecordSeparatorCode);
|
|
425
425
|
class ue {
|
|
426
426
|
// Handshake request is always JSON
|
|
427
427
|
writeHandshakeRequest(e) {
|
|
428
|
-
return
|
|
428
|
+
return w.write(JSON.stringify(e));
|
|
429
429
|
}
|
|
430
430
|
parseHandshakeResponse(e) {
|
|
431
431
|
let t, n;
|
|
432
|
-
if (
|
|
433
|
-
const a = new Uint8Array(e), l = a.indexOf(
|
|
432
|
+
if (E(e)) {
|
|
433
|
+
const a = new Uint8Array(e), l = a.indexOf(w.RecordSeparatorCode);
|
|
434
434
|
if (l === -1)
|
|
435
435
|
throw new Error("Message is incomplete.");
|
|
436
436
|
const u = l + 1;
|
|
437
437
|
t = String.fromCharCode.apply(null, Array.prototype.slice.call(a.slice(0, u))), n = a.byteLength > u ? a.slice(u).buffer : null;
|
|
438
438
|
} else {
|
|
439
|
-
const a = e, l = a.indexOf(
|
|
439
|
+
const a = e, l = a.indexOf(w.RecordSeparator);
|
|
440
440
|
if (l === -1)
|
|
441
441
|
throw new Error("Message is incomplete.");
|
|
442
442
|
const u = l + 1;
|
|
443
443
|
t = a.substring(0, u), n = a.length > u ? a.substring(u) : null;
|
|
444
444
|
}
|
|
445
|
-
const o =
|
|
446
|
-
if (
|
|
445
|
+
const o = w.parse(t), r = JSON.parse(o[0]);
|
|
446
|
+
if (r.type)
|
|
447
447
|
throw new Error("Expected a handshake response from the server.");
|
|
448
|
-
return [n,
|
|
448
|
+
return [n, r];
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
var h;
|
|
@@ -482,11 +482,11 @@ class ge {
|
|
|
482
482
|
if (this._isInvocationMessage(e)) {
|
|
483
483
|
this._totalMessageCount++;
|
|
484
484
|
let o = () => {
|
|
485
|
-
},
|
|
485
|
+
}, r = () => {
|
|
486
486
|
};
|
|
487
|
-
|
|
488
|
-
o = c,
|
|
489
|
-
})), this._messages.push(new _e(t, this._totalMessageCount, o,
|
|
487
|
+
E(t) ? this._bufferedByteCount += t.byteLength : this._bufferedByteCount += t.length, this._bufferedByteCount >= this._bufferSize && (n = new Promise((c, a) => {
|
|
488
|
+
o = c, r = a;
|
|
489
|
+
})), this._messages.push(new _e(t, this._totalMessageCount, o, r));
|
|
490
490
|
}
|
|
491
491
|
try {
|
|
492
492
|
this._reconnectInProgress || await this._connection.send(t);
|
|
@@ -500,7 +500,7 @@ class ge {
|
|
|
500
500
|
for (let n = 0; n < this._messages.length; n++) {
|
|
501
501
|
const o = this._messages[n];
|
|
502
502
|
if (o._id <= e.sequenceId)
|
|
503
|
-
t = n,
|
|
503
|
+
t = n, E(o._message) ? this._bufferedByteCount -= o._message.byteLength : this._bufferedByteCount -= o._message.length, o._resolver();
|
|
504
504
|
else if (this._bufferedByteCount < this._bufferSize)
|
|
505
505
|
o._resolver();
|
|
506
506
|
else
|
|
@@ -580,13 +580,13 @@ class H {
|
|
|
580
580
|
// create method that can be used by HubConnectionBuilder. An "internal" constructor would just
|
|
581
581
|
// be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
|
|
582
582
|
// public parameter-less constructor.
|
|
583
|
-
static create(e, t, n, o,
|
|
584
|
-
return new H(e, t, n, o,
|
|
583
|
+
static create(e, t, n, o, r, c, a) {
|
|
584
|
+
return new H(e, t, n, o, r, c, a);
|
|
585
585
|
}
|
|
586
|
-
constructor(e, t, n, o,
|
|
586
|
+
constructor(e, t, n, o, r, c, a) {
|
|
587
587
|
this._nextKeepAlive = 0, this._freezeEventListener = () => {
|
|
588
|
-
this._logger.log(
|
|
589
|
-
}, p.isRequired(e, "connection"), p.isRequired(t, "logger"), p.isRequired(n, "protocol"), this.serverTimeoutInMilliseconds =
|
|
588
|
+
this._logger.log(i.Warning, "The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep");
|
|
589
|
+
}, p.isRequired(e, "connection"), p.isRequired(t, "logger"), p.isRequired(n, "protocol"), this.serverTimeoutInMilliseconds = r ?? fe, this.keepAliveIntervalInMilliseconds = c ?? pe, this._statefulReconnectBufferSize = a ?? me, this._logger = t, this._protocol = n, this.connection = e, this._reconnectPolicy = o, this._handshakeProtocol = new ue(), this.connection.onreceive = (l) => this._processIncomingData(l), this.connection.onclose = (l) => this._connectionClosed(l), this._callbacks = {}, this._methods = {}, this._closedCallbacks = [], this._reconnectingCallbacks = [], this._reconnectedCallbacks = [], this._invocationId = 0, this._receivedHandshakeResponse = !1, this._connectionState = g.Disconnected, this._connectionStarted = !1, this._cachedPingMessage = this._protocol.writeMessage({ type: h.Ping });
|
|
590
590
|
}
|
|
591
591
|
/** Indicates the state of the {@link HubConnection} to the server. */
|
|
592
592
|
get state() {
|
|
@@ -624,11 +624,11 @@ class H {
|
|
|
624
624
|
async _startWithStateTransitions() {
|
|
625
625
|
if (this._connectionState !== g.Disconnected)
|
|
626
626
|
return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));
|
|
627
|
-
this._connectionState = g.Connecting, this._logger.log(
|
|
627
|
+
this._connectionState = g.Connecting, this._logger.log(i.Debug, "Starting HubConnection.");
|
|
628
628
|
try {
|
|
629
|
-
await this._startInternal(), _.isBrowser && window.document.addEventListener("freeze", this._freezeEventListener), this._connectionState = g.Connected, this._connectionStarted = !0, this._logger.log(
|
|
629
|
+
await this._startInternal(), _.isBrowser && window.document.addEventListener("freeze", this._freezeEventListener), this._connectionState = g.Connected, this._connectionStarted = !0, this._logger.log(i.Debug, "HubConnection connected successfully.");
|
|
630
630
|
} catch (e) {
|
|
631
|
-
return this._connectionState = g.Disconnected, this._logger.log(
|
|
631
|
+
return this._connectionState = g.Disconnected, this._logger.log(i.Debug, `HubConnection failed to start successfully because of error '${e}'.`), Promise.reject(e);
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
async _startInternal() {
|
|
@@ -644,14 +644,14 @@ class H {
|
|
|
644
644
|
protocol: this._protocol.name,
|
|
645
645
|
version: t
|
|
646
646
|
};
|
|
647
|
-
if (this._logger.log(
|
|
647
|
+
if (this._logger.log(i.Debug, "Sending handshake request."), await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(n)), this._logger.log(i.Information, `Using HubProtocol '${this._protocol.name}'.`), this._cleanupTimeout(), this._resetTimeoutPeriod(), this._resetKeepAliveInterval(), await e, this._stopDuringStartError)
|
|
648
648
|
throw this._stopDuringStartError;
|
|
649
649
|
(this.connection.features.reconnect || !1) && (this._messageBuffer = new ge(this._protocol, this.connection, this._statefulReconnectBufferSize), this.connection.features.disconnected = this._messageBuffer._disconnected.bind(this._messageBuffer), this.connection.features.resend = () => {
|
|
650
650
|
if (this._messageBuffer)
|
|
651
651
|
return this._messageBuffer._resend();
|
|
652
652
|
}), this.connection.features.inherentKeepAlive || await this._sendMessage(this._cachedPingMessage);
|
|
653
653
|
} catch (t) {
|
|
654
|
-
throw this._logger.log(
|
|
654
|
+
throw this._logger.log(i.Debug, `Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`), this._cleanupTimeout(), this._cleanupPingTimer(), await this.connection.stop(t), t;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
657
|
/** Stops the connection.
|
|
@@ -668,11 +668,11 @@ class H {
|
|
|
668
668
|
}
|
|
669
669
|
_stopInternal(e) {
|
|
670
670
|
if (this._connectionState === g.Disconnected)
|
|
671
|
-
return this._logger.log(
|
|
671
|
+
return this._logger.log(i.Debug, `Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`), Promise.resolve();
|
|
672
672
|
if (this._connectionState === g.Disconnecting)
|
|
673
|
-
return this._logger.log(
|
|
673
|
+
return this._logger.log(i.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`), this._stopPromise;
|
|
674
674
|
const t = this._connectionState;
|
|
675
|
-
return this._connectionState = g.Disconnecting, this._logger.log(
|
|
675
|
+
return this._connectionState = g.Disconnecting, this._logger.log(i.Debug, "Stopping HubConnection."), this._reconnectDelayHandle ? (this._logger.log(i.Debug, "Connection stopped during reconnect delay. Done reconnecting."), clearTimeout(this._reconnectDelayHandle), this._reconnectDelayHandle = void 0, this._completeClose(), Promise.resolve()) : (t === g.Connected && this._sendCloseMessage(), this._cleanupTimeout(), this._cleanupPingTimer(), this._stopDuringStartError = e || new b("The connection was stopped before the hub handshake could complete."), this.connection.stop(e));
|
|
676
676
|
}
|
|
677
677
|
async _sendCloseMessage() {
|
|
678
678
|
try {
|
|
@@ -688,19 +688,19 @@ class H {
|
|
|
688
688
|
* @returns {IStreamResult<T>} An object that yields results from the server as they are received.
|
|
689
689
|
*/
|
|
690
690
|
stream(e, ...t) {
|
|
691
|
-
const [n, o] = this._replaceStreamingParams(t),
|
|
691
|
+
const [n, o] = this._replaceStreamingParams(t), r = this._createStreamInvocation(e, t, o);
|
|
692
692
|
let c;
|
|
693
693
|
const a = new de();
|
|
694
694
|
return a.cancelCallback = () => {
|
|
695
|
-
const l = this._createCancelInvocation(
|
|
696
|
-
return delete this._callbacks[
|
|
697
|
-
}, this._callbacks[
|
|
695
|
+
const l = this._createCancelInvocation(r.invocationId);
|
|
696
|
+
return delete this._callbacks[r.invocationId], c.then(() => this._sendWithProtocol(l));
|
|
697
|
+
}, this._callbacks[r.invocationId] = (l, u) => {
|
|
698
698
|
if (u) {
|
|
699
699
|
a.error(u);
|
|
700
700
|
return;
|
|
701
701
|
} else l && (l.type === h.Completion ? l.error ? a.error(new Error(l.error)) : a.complete() : a.next(l.item));
|
|
702
|
-
}, c = this._sendWithProtocol(
|
|
703
|
-
a.error(l), delete this._callbacks[
|
|
702
|
+
}, c = this._sendWithProtocol(r).catch((l) => {
|
|
703
|
+
a.error(l), delete this._callbacks[r.invocationId];
|
|
704
704
|
}), this._launchStreams(n, c), a;
|
|
705
705
|
}
|
|
706
706
|
_sendMessage(e) {
|
|
@@ -723,8 +723,8 @@ class H {
|
|
|
723
723
|
* @returns {Promise<void>} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
|
|
724
724
|
*/
|
|
725
725
|
send(e, ...t) {
|
|
726
|
-
const [n, o] = this._replaceStreamingParams(t),
|
|
727
|
-
return this._launchStreams(n,
|
|
726
|
+
const [n, o] = this._replaceStreamingParams(t), r = this._sendWithProtocol(this._createInvocation(e, t, !0, o));
|
|
727
|
+
return this._launchStreams(n, r), r;
|
|
728
728
|
}
|
|
729
729
|
/** Invokes a hub method on the server using the specified name and arguments.
|
|
730
730
|
*
|
|
@@ -738,16 +738,16 @@ class H {
|
|
|
738
738
|
* @returns {Promise<T>} A Promise that resolves with the result of the server method (if any), or rejects with an error.
|
|
739
739
|
*/
|
|
740
740
|
invoke(e, ...t) {
|
|
741
|
-
const [n, o] = this._replaceStreamingParams(t),
|
|
741
|
+
const [n, o] = this._replaceStreamingParams(t), r = this._createInvocation(e, t, !1, o);
|
|
742
742
|
return new Promise((a, l) => {
|
|
743
|
-
this._callbacks[
|
|
744
|
-
if (
|
|
745
|
-
l(
|
|
743
|
+
this._callbacks[r.invocationId] = (d, y) => {
|
|
744
|
+
if (y) {
|
|
745
|
+
l(y);
|
|
746
746
|
return;
|
|
747
747
|
} else d && (d.type === h.Completion ? d.error ? l(new Error(d.error)) : a(d.result) : l(new Error(`Unexpected message type: ${d.type}`)));
|
|
748
748
|
};
|
|
749
|
-
const u = this._sendWithProtocol(
|
|
750
|
-
l(d), delete this._callbacks[
|
|
749
|
+
const u = this._sendWithProtocol(r).catch((d) => {
|
|
750
|
+
l(d), delete this._callbacks[r.invocationId];
|
|
751
751
|
});
|
|
752
752
|
this._launchStreams(n, u);
|
|
753
753
|
});
|
|
@@ -796,7 +796,7 @@ class H {
|
|
|
796
796
|
switch (n.type) {
|
|
797
797
|
case h.Invocation:
|
|
798
798
|
this._invokeClientMethod(n).catch((o) => {
|
|
799
|
-
this._logger.log(
|
|
799
|
+
this._logger.log(i.Error, `Invoke client method threw error: ${A(o)}`);
|
|
800
800
|
});
|
|
801
801
|
break;
|
|
802
802
|
case h.StreamItem:
|
|
@@ -806,8 +806,8 @@ class H {
|
|
|
806
806
|
n.type === h.Completion && delete this._callbacks[n.invocationId];
|
|
807
807
|
try {
|
|
808
808
|
o(n);
|
|
809
|
-
} catch (
|
|
810
|
-
this._logger.log(
|
|
809
|
+
} catch (r) {
|
|
810
|
+
this._logger.log(i.Error, `Stream callback threw error: ${A(r)}`);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
813
|
break;
|
|
@@ -815,7 +815,7 @@ class H {
|
|
|
815
815
|
case h.Ping:
|
|
816
816
|
break;
|
|
817
817
|
case h.Close: {
|
|
818
|
-
this._logger.log(
|
|
818
|
+
this._logger.log(i.Information, "Close message received from server.");
|
|
819
819
|
const o = n.error ? new Error("Server returned an error on close: " + n.error) : void 0;
|
|
820
820
|
n.allowReconnect === !0 ? this.connection.stop(o) : this._stopPromise = this._stopInternal(o);
|
|
821
821
|
break;
|
|
@@ -827,7 +827,7 @@ class H {
|
|
|
827
827
|
this._messageBuffer && this._messageBuffer._resetSequence(n);
|
|
828
828
|
break;
|
|
829
829
|
default:
|
|
830
|
-
this._logger.log(
|
|
830
|
+
this._logger.log(i.Warning, `Invalid message type: ${n.type}.`);
|
|
831
831
|
break;
|
|
832
832
|
}
|
|
833
833
|
}
|
|
@@ -838,18 +838,18 @@ class H {
|
|
|
838
838
|
try {
|
|
839
839
|
[n, t] = this._handshakeProtocol.parseHandshakeResponse(e);
|
|
840
840
|
} catch (o) {
|
|
841
|
-
const
|
|
842
|
-
this._logger.log(
|
|
843
|
-
const c = new Error(
|
|
841
|
+
const r = "Error parsing handshake response: " + o;
|
|
842
|
+
this._logger.log(i.Error, r);
|
|
843
|
+
const c = new Error(r);
|
|
844
844
|
throw this._handshakeRejecter(c), c;
|
|
845
845
|
}
|
|
846
846
|
if (t.error) {
|
|
847
847
|
const o = "Server returned handshake error: " + t.error;
|
|
848
|
-
this._logger.log(
|
|
849
|
-
const
|
|
850
|
-
throw this._handshakeRejecter(
|
|
848
|
+
this._logger.log(i.Error, o);
|
|
849
|
+
const r = new Error(o);
|
|
850
|
+
throw this._handshakeRejecter(r), r;
|
|
851
851
|
} else
|
|
852
|
-
this._logger.log(
|
|
852
|
+
this._logger.log(i.Debug, "Server handshake complete.");
|
|
853
853
|
return this._handshakeResolver(), n;
|
|
854
854
|
}
|
|
855
855
|
_resetKeepAliveInterval() {
|
|
@@ -875,22 +875,22 @@ class H {
|
|
|
875
875
|
async _invokeClientMethod(e) {
|
|
876
876
|
const t = e.target.toLowerCase(), n = this._methods[t];
|
|
877
877
|
if (!n) {
|
|
878
|
-
this._logger.log(
|
|
878
|
+
this._logger.log(i.Warning, `No client method with the name '${t}' found.`), e.invocationId && (this._logger.log(i.Warning, `No result given for '${t}' method and invocation ID '${e.invocationId}'.`), await this._sendWithProtocol(this._createCompletionMessage(e.invocationId, "Client didn't provide a result.", null)));
|
|
879
879
|
return;
|
|
880
880
|
}
|
|
881
|
-
const o = n.slice(),
|
|
881
|
+
const o = n.slice(), r = !!e.invocationId;
|
|
882
882
|
let c, a, l;
|
|
883
883
|
for (const u of o)
|
|
884
884
|
try {
|
|
885
885
|
const d = c;
|
|
886
|
-
c = await u.apply(this, e.arguments),
|
|
886
|
+
c = await u.apply(this, e.arguments), r && c && d && (this._logger.log(i.Error, `Multiple results provided for '${t}'. Sending error to server.`), l = this._createCompletionMessage(e.invocationId, "Client provided multiple results.", null)), a = void 0;
|
|
887
887
|
} catch (d) {
|
|
888
|
-
a = d, this._logger.log(
|
|
888
|
+
a = d, this._logger.log(i.Error, `A callback for the method '${t}' threw error '${d}'.`);
|
|
889
889
|
}
|
|
890
|
-
l ? await this._sendWithProtocol(l) :
|
|
890
|
+
l ? await this._sendWithProtocol(l) : r ? (a ? l = this._createCompletionMessage(e.invocationId, `${a}`, null) : c !== void 0 ? l = this._createCompletionMessage(e.invocationId, null, c) : (this._logger.log(i.Warning, `No result given for '${t}' method and invocation ID '${e.invocationId}'.`), l = this._createCompletionMessage(e.invocationId, "Client didn't provide a result.", null)), await this._sendWithProtocol(l)) : c && this._logger.log(i.Error, `Result given for '${t}' method but server is not expecting a result.`);
|
|
891
891
|
}
|
|
892
892
|
_connectionClosed(e) {
|
|
893
|
-
this._logger.log(
|
|
893
|
+
this._logger.log(i.Debug, `HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`), this._stopDuringStartError = this._stopDuringStartError || e || new b("The underlying connection was closed before the hub handshake could complete."), this._handshakeResolver && this._handshakeResolver(), this._cancelCallbacksWithError(e || new Error("Invocation canceled due to the underlying connection being closed.")), this._cleanupTimeout(), this._cleanupPingTimer(), this._connectionState === g.Disconnecting ? this._completeClose(e) : this._connectionState === g.Connected && this._reconnectPolicy ? this._reconnect(e) : this._connectionState === g.Connected && this._completeClose(e);
|
|
894
894
|
}
|
|
895
895
|
_completeClose(e) {
|
|
896
896
|
if (this._connectionStarted) {
|
|
@@ -898,52 +898,52 @@ class H {
|
|
|
898
898
|
try {
|
|
899
899
|
this._closedCallbacks.forEach((t) => t.apply(this, [e]));
|
|
900
900
|
} catch (t) {
|
|
901
|
-
this._logger.log(
|
|
901
|
+
this._logger.log(i.Error, `An onclose callback called with error '${e}' threw error '${t}'.`);
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
905
|
async _reconnect(e) {
|
|
906
906
|
const t = Date.now();
|
|
907
|
-
let n = 0, o = e !== void 0 ? e : new Error("Attempting to reconnect due to a unknown error."),
|
|
908
|
-
if (
|
|
909
|
-
this._logger.log(
|
|
907
|
+
let n = 0, o = e !== void 0 ? e : new Error("Attempting to reconnect due to a unknown error."), r = this._getNextRetryDelay(n++, 0, o);
|
|
908
|
+
if (r === null) {
|
|
909
|
+
this._logger.log(i.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."), this._completeClose(e);
|
|
910
910
|
return;
|
|
911
911
|
}
|
|
912
|
-
if (this._connectionState = g.Reconnecting, e ? this._logger.log(
|
|
912
|
+
if (this._connectionState = g.Reconnecting, e ? this._logger.log(i.Information, `Connection reconnecting because of error '${e}'.`) : this._logger.log(i.Information, "Connection reconnecting."), this._reconnectingCallbacks.length !== 0) {
|
|
913
913
|
try {
|
|
914
914
|
this._reconnectingCallbacks.forEach((c) => c.apply(this, [e]));
|
|
915
915
|
} catch (c) {
|
|
916
|
-
this._logger.log(
|
|
916
|
+
this._logger.log(i.Error, `An onreconnecting callback called with error '${e}' threw error '${c}'.`);
|
|
917
917
|
}
|
|
918
918
|
if (this._connectionState !== g.Reconnecting) {
|
|
919
|
-
this._logger.log(
|
|
919
|
+
this._logger.log(i.Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
|
|
920
920
|
return;
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
for (;
|
|
924
|
-
if (this._logger.log(
|
|
925
|
-
this._reconnectDelayHandle = setTimeout(c,
|
|
923
|
+
for (; r !== null; ) {
|
|
924
|
+
if (this._logger.log(i.Information, `Reconnect attempt number ${n} will start in ${r} ms.`), await new Promise((c) => {
|
|
925
|
+
this._reconnectDelayHandle = setTimeout(c, r);
|
|
926
926
|
}), this._reconnectDelayHandle = void 0, this._connectionState !== g.Reconnecting) {
|
|
927
|
-
this._logger.log(
|
|
927
|
+
this._logger.log(i.Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
|
|
928
928
|
return;
|
|
929
929
|
}
|
|
930
930
|
try {
|
|
931
|
-
if (await this._startInternal(), this._connectionState = g.Connected, this._logger.log(
|
|
931
|
+
if (await this._startInternal(), this._connectionState = g.Connected, this._logger.log(i.Information, "HubConnection reconnected successfully."), this._reconnectedCallbacks.length !== 0)
|
|
932
932
|
try {
|
|
933
933
|
this._reconnectedCallbacks.forEach((c) => c.apply(this, [this.connection.connectionId]));
|
|
934
934
|
} catch (c) {
|
|
935
|
-
this._logger.log(
|
|
935
|
+
this._logger.log(i.Error, `An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${c}'.`);
|
|
936
936
|
}
|
|
937
937
|
return;
|
|
938
938
|
} catch (c) {
|
|
939
|
-
if (this._logger.log(
|
|
940
|
-
this._logger.log(
|
|
939
|
+
if (this._logger.log(i.Information, `Reconnect attempt failed because of error '${c}'.`), this._connectionState !== g.Reconnecting) {
|
|
940
|
+
this._logger.log(i.Debug, `Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`), this._connectionState === g.Disconnecting && this._completeClose();
|
|
941
941
|
return;
|
|
942
942
|
}
|
|
943
|
-
o = c instanceof Error ? c : new Error(c.toString()),
|
|
943
|
+
o = c instanceof Error ? c : new Error(c.toString()), r = this._getNextRetryDelay(n++, Date.now() - t, o);
|
|
944
944
|
}
|
|
945
945
|
}
|
|
946
|
-
this._logger.log(
|
|
946
|
+
this._logger.log(i.Information, `Reconnect retries have been exhausted after ${Date.now() - t} ms and ${n} failed attempts. Connection disconnecting.`), this._completeClose();
|
|
947
947
|
}
|
|
948
948
|
_getNextRetryDelay(e, t, n) {
|
|
949
949
|
try {
|
|
@@ -953,7 +953,7 @@ class H {
|
|
|
953
953
|
retryReason: n
|
|
954
954
|
});
|
|
955
955
|
} catch (o) {
|
|
956
|
-
return this._logger.log(
|
|
956
|
+
return this._logger.log(i.Error, `IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${o}'.`), null;
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
_cancelCallbacksWithError(e) {
|
|
@@ -962,8 +962,8 @@ class H {
|
|
|
962
962
|
const o = t[n];
|
|
963
963
|
try {
|
|
964
964
|
o(null, e);
|
|
965
|
-
} catch (
|
|
966
|
-
this._logger.log(
|
|
965
|
+
} catch (r) {
|
|
966
|
+
this._logger.log(i.Error, `Stream 'error' callback called with '${e}' threw error: ${A(r)}`);
|
|
967
967
|
}
|
|
968
968
|
});
|
|
969
969
|
}
|
|
@@ -986,16 +986,16 @@ class H {
|
|
|
986
986
|
type: h.Invocation
|
|
987
987
|
};
|
|
988
988
|
{
|
|
989
|
-
const
|
|
989
|
+
const r = this._invocationId;
|
|
990
990
|
return this._invocationId++, o.length !== 0 ? {
|
|
991
991
|
arguments: t,
|
|
992
|
-
invocationId:
|
|
992
|
+
invocationId: r.toString(),
|
|
993
993
|
streamIds: o,
|
|
994
994
|
target: e,
|
|
995
995
|
type: h.Invocation
|
|
996
996
|
} : {
|
|
997
997
|
arguments: t,
|
|
998
|
-
invocationId:
|
|
998
|
+
invocationId: r.toString(),
|
|
999
999
|
target: e,
|
|
1000
1000
|
type: h.Invocation
|
|
1001
1001
|
};
|
|
@@ -1010,8 +1010,8 @@ class H {
|
|
|
1010
1010
|
t = t.then(() => this._sendWithProtocol(this._createCompletionMessage(n)));
|
|
1011
1011
|
},
|
|
1012
1012
|
error: (o) => {
|
|
1013
|
-
let
|
|
1014
|
-
o instanceof Error ?
|
|
1013
|
+
let r;
|
|
1014
|
+
o instanceof Error ? r = o.message : o && o.toString ? r = o.toString() : r = "Unknown error", t = t.then(() => this._sendWithProtocol(this._createCompletionMessage(n, r)));
|
|
1015
1015
|
},
|
|
1016
1016
|
next: (o) => {
|
|
1017
1017
|
t = t.then(() => this._sendWithProtocol(this._createStreamItemMessage(n, o)));
|
|
@@ -1022,10 +1022,10 @@ class H {
|
|
|
1022
1022
|
_replaceStreamingParams(e) {
|
|
1023
1023
|
const t = [], n = [];
|
|
1024
1024
|
for (let o = 0; o < e.length; o++) {
|
|
1025
|
-
const
|
|
1026
|
-
if (this._isObservable(
|
|
1025
|
+
const r = e[o];
|
|
1026
|
+
if (this._isObservable(r)) {
|
|
1027
1027
|
const c = this._invocationId;
|
|
1028
|
-
this._invocationId++, t[c] =
|
|
1028
|
+
this._invocationId++, t[c] = r, n.push(c.toString()), e.splice(o, 1);
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
1031
|
return [t, n];
|
|
@@ -1077,7 +1077,7 @@ class H {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
1079
|
const we = [0, 2e3, 1e4, 3e4, null];
|
|
1080
|
-
class
|
|
1080
|
+
class L {
|
|
1081
1081
|
constructor(e) {
|
|
1082
1082
|
this._retryDelays = e !== void 0 ? [...e, null] : we;
|
|
1083
1083
|
}
|
|
@@ -1085,10 +1085,10 @@ class B {
|
|
|
1085
1085
|
return this._retryDelays[e.previousRetryCount];
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
|
-
class
|
|
1088
|
+
class k {
|
|
1089
1089
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1090
|
+
k.Authorization = "Authorization";
|
|
1091
|
+
k.Cookie = "Cookie";
|
|
1092
1092
|
class be extends x {
|
|
1093
1093
|
constructor(e, t) {
|
|
1094
1094
|
super(), this._innerClient = e, this._accessTokenFactory = t;
|
|
@@ -1100,7 +1100,7 @@ class be extends x {
|
|
|
1100
1100
|
return t && n.statusCode === 401 && this._accessTokenFactory ? (this._accessToken = await this._accessTokenFactory(), this._setAuthorizationHeader(e), await this._innerClient.send(e)) : n;
|
|
1101
1101
|
}
|
|
1102
1102
|
_setAuthorizationHeader(e) {
|
|
1103
|
-
e.headers || (e.headers = {}), this._accessToken ? e.headers[
|
|
1103
|
+
e.headers || (e.headers = {}), this._accessToken ? e.headers[k.Authorization] = `Bearer ${this._accessToken}` : this._accessTokenFactory && e.headers[k.Authorization] && delete e.headers[k.Authorization];
|
|
1104
1104
|
}
|
|
1105
1105
|
getCookieString(e) {
|
|
1106
1106
|
return this._innerClient.getCookieString(e);
|
|
@@ -1137,74 +1137,74 @@ class j {
|
|
|
1137
1137
|
this._httpClient = e, this._logger = t, this._pollAbort = new Se(), this._options = n, this._running = !1, this.onreceive = null, this.onclose = null;
|
|
1138
1138
|
}
|
|
1139
1139
|
async connect(e, t) {
|
|
1140
|
-
if (p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._url = e, this._logger.log(
|
|
1140
|
+
if (p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._url = e, this._logger.log(i.Trace, "(LongPolling transport) Connecting."), t === m.Binary && typeof XMLHttpRequest < "u" && typeof new XMLHttpRequest().responseType != "string")
|
|
1141
1141
|
throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
|
|
1142
|
-
const [n, o] =
|
|
1142
|
+
const [n, o] = I(), r = { [n]: o, ...this._options.headers }, c = {
|
|
1143
1143
|
abortSignal: this._pollAbort.signal,
|
|
1144
|
-
headers:
|
|
1144
|
+
headers: r,
|
|
1145
1145
|
timeout: 1e5,
|
|
1146
1146
|
withCredentials: this._options.withCredentials
|
|
1147
1147
|
};
|
|
1148
1148
|
t === m.Binary && (c.responseType = "arraybuffer");
|
|
1149
1149
|
const a = `${e}&_=${Date.now()}`;
|
|
1150
|
-
this._logger.log(
|
|
1150
|
+
this._logger.log(i.Trace, `(LongPolling transport) polling: ${a}.`);
|
|
1151
1151
|
const l = await this._httpClient.get(a, c);
|
|
1152
|
-
l.statusCode !== 200 ? (this._logger.log(
|
|
1152
|
+
l.statusCode !== 200 ? (this._logger.log(i.Error, `(LongPolling transport) Unexpected response code: ${l.statusCode}.`), this._closeError = new v(l.statusText || "", l.statusCode), this._running = !1) : this._running = !0, this._receiving = this._poll(this._url, c);
|
|
1153
1153
|
}
|
|
1154
1154
|
async _poll(e, t) {
|
|
1155
1155
|
try {
|
|
1156
1156
|
for (; this._running; )
|
|
1157
1157
|
try {
|
|
1158
1158
|
const n = `${e}&_=${Date.now()}`;
|
|
1159
|
-
this._logger.log(
|
|
1159
|
+
this._logger.log(i.Trace, `(LongPolling transport) polling: ${n}.`);
|
|
1160
1160
|
const o = await this._httpClient.get(n, t);
|
|
1161
|
-
o.statusCode === 204 ? (this._logger.log(
|
|
1161
|
+
o.statusCode === 204 ? (this._logger.log(i.Information, "(LongPolling transport) Poll terminated by server."), this._running = !1) : o.statusCode !== 200 ? (this._logger.log(i.Error, `(LongPolling transport) Unexpected response code: ${o.statusCode}.`), this._closeError = new v(o.statusText || "", o.statusCode), this._running = !1) : o.content ? (this._logger.log(i.Trace, `(LongPolling transport) data received. ${R(o.content, this._options.logMessageContent)}.`), this.onreceive && this.onreceive(o.content)) : this._logger.log(i.Trace, "(LongPolling transport) Poll timed out, reissuing.");
|
|
1162
1162
|
} catch (n) {
|
|
1163
|
-
this._running ? n instanceof M ? this._logger.log(
|
|
1163
|
+
this._running ? n instanceof M ? this._logger.log(i.Trace, "(LongPolling transport) Poll timed out, reissuing.") : (this._closeError = n, this._running = !1) : this._logger.log(i.Trace, `(LongPolling transport) Poll errored after shutdown: ${n.message}`);
|
|
1164
1164
|
}
|
|
1165
1165
|
} finally {
|
|
1166
|
-
this._logger.log(
|
|
1166
|
+
this._logger.log(i.Trace, "(LongPolling transport) Polling complete."), this.pollAborted || this._raiseOnClose();
|
|
1167
1167
|
}
|
|
1168
1168
|
}
|
|
1169
1169
|
async send(e) {
|
|
1170
1170
|
return this._running ? z(this._logger, "LongPolling", this._httpClient, this._url, e, this._options) : Promise.reject(new Error("Cannot send until the transport is connected"));
|
|
1171
1171
|
}
|
|
1172
1172
|
async stop() {
|
|
1173
|
-
this._logger.log(
|
|
1173
|
+
this._logger.log(i.Trace, "(LongPolling transport) Stopping polling."), this._running = !1, this._pollAbort.abort();
|
|
1174
1174
|
try {
|
|
1175
|
-
await this._receiving, this._logger.log(
|
|
1176
|
-
const e = {}, [t, n] =
|
|
1175
|
+
await this._receiving, this._logger.log(i.Trace, `(LongPolling transport) sending DELETE request to ${this._url}.`);
|
|
1176
|
+
const e = {}, [t, n] = I();
|
|
1177
1177
|
e[t] = n;
|
|
1178
1178
|
const o = {
|
|
1179
1179
|
headers: { ...e, ...this._options.headers },
|
|
1180
1180
|
timeout: this._options.timeout,
|
|
1181
1181
|
withCredentials: this._options.withCredentials
|
|
1182
1182
|
};
|
|
1183
|
-
let
|
|
1183
|
+
let r;
|
|
1184
1184
|
try {
|
|
1185
1185
|
await this._httpClient.delete(this._url, o);
|
|
1186
1186
|
} catch (c) {
|
|
1187
|
-
|
|
1187
|
+
r = c;
|
|
1188
1188
|
}
|
|
1189
|
-
|
|
1189
|
+
r ? r instanceof v && (r.statusCode === 404 ? this._logger.log(i.Trace, "(LongPolling transport) A 404 response was returned from sending a DELETE request.") : this._logger.log(i.Trace, `(LongPolling transport) Error sending a DELETE request: ${r}`)) : this._logger.log(i.Trace, "(LongPolling transport) DELETE request accepted.");
|
|
1190
1190
|
} finally {
|
|
1191
|
-
this._logger.log(
|
|
1191
|
+
this._logger.log(i.Trace, "(LongPolling transport) Stop finished."), this._raiseOnClose();
|
|
1192
1192
|
}
|
|
1193
1193
|
}
|
|
1194
1194
|
_raiseOnClose() {
|
|
1195
1195
|
if (this.onclose) {
|
|
1196
1196
|
let e = "(LongPolling transport) Firing onclose event.";
|
|
1197
|
-
this._closeError && (e += " Error: " + this._closeError), this._logger.log(
|
|
1197
|
+
this._closeError && (e += " Error: " + this._closeError), this._logger.log(i.Trace, e), this.onclose(this._closeError);
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
|
-
class
|
|
1201
|
+
class Ce {
|
|
1202
1202
|
constructor(e, t, n, o) {
|
|
1203
1203
|
this._httpClient = e, this._accessToken = t, this._logger = n, this._options = o, this.onreceive = null, this.onclose = null;
|
|
1204
1204
|
}
|
|
1205
1205
|
async connect(e, t) {
|
|
1206
|
-
return p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._logger.log(
|
|
1207
|
-
let
|
|
1206
|
+
return p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._logger.log(i.Trace, "(SSE transport) Connecting."), this._url = e, this._accessToken && (e += (e.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(this._accessToken)}`), new Promise((n, o) => {
|
|
1207
|
+
let r = !1;
|
|
1208
1208
|
if (t !== m.Text) {
|
|
1209
1209
|
o(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
|
|
1210
1210
|
return;
|
|
@@ -1215,22 +1215,22 @@ class ye {
|
|
|
1215
1215
|
else {
|
|
1216
1216
|
const a = this._httpClient.getCookieString(e), l = {};
|
|
1217
1217
|
l.Cookie = a;
|
|
1218
|
-
const [u, d] =
|
|
1218
|
+
const [u, d] = I();
|
|
1219
1219
|
l[u] = d, c = new this._options.EventSource(e, { withCredentials: this._options.withCredentials, headers: { ...l, ...this._options.headers } });
|
|
1220
1220
|
}
|
|
1221
1221
|
try {
|
|
1222
1222
|
c.onmessage = (a) => {
|
|
1223
1223
|
if (this.onreceive)
|
|
1224
1224
|
try {
|
|
1225
|
-
this._logger.log(
|
|
1225
|
+
this._logger.log(i.Trace, `(SSE transport) data received. ${R(a.data, this._options.logMessageContent)}.`), this.onreceive(a.data);
|
|
1226
1226
|
} catch (l) {
|
|
1227
1227
|
this._close(l);
|
|
1228
1228
|
return;
|
|
1229
1229
|
}
|
|
1230
1230
|
}, c.onerror = (a) => {
|
|
1231
|
-
|
|
1231
|
+
r ? this._close() : o(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."));
|
|
1232
1232
|
}, c.onopen = () => {
|
|
1233
|
-
this._logger.log(
|
|
1233
|
+
this._logger.log(i.Information, `SSE connected to ${this._url}`), this._eventSource = c, r = !0, n();
|
|
1234
1234
|
};
|
|
1235
1235
|
} catch (a) {
|
|
1236
1236
|
o(a);
|
|
@@ -1248,32 +1248,32 @@ class ye {
|
|
|
1248
1248
|
this._eventSource && (this._eventSource.close(), this._eventSource = void 0, this.onclose && this.onclose(e));
|
|
1249
1249
|
}
|
|
1250
1250
|
}
|
|
1251
|
-
class
|
|
1252
|
-
constructor(e, t, n, o,
|
|
1253
|
-
this._logger = n, this._accessTokenFactory = t, this._logMessageContent = o, this._webSocketConstructor =
|
|
1251
|
+
class ye {
|
|
1252
|
+
constructor(e, t, n, o, r, c) {
|
|
1253
|
+
this._logger = n, this._accessTokenFactory = t, this._logMessageContent = o, this._webSocketConstructor = r, this._httpClient = e, this.onreceive = null, this.onclose = null, this._headers = c;
|
|
1254
1254
|
}
|
|
1255
1255
|
async connect(e, t) {
|
|
1256
|
-
p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._logger.log(
|
|
1256
|
+
p.isRequired(e, "url"), p.isRequired(t, "transferFormat"), p.isIn(t, m, "transferFormat"), this._logger.log(i.Trace, "(WebSockets transport) Connecting.");
|
|
1257
1257
|
let n;
|
|
1258
|
-
return this._accessTokenFactory && (n = await this._accessTokenFactory()), new Promise((o,
|
|
1258
|
+
return this._accessTokenFactory && (n = await this._accessTokenFactory()), new Promise((o, r) => {
|
|
1259
1259
|
e = e.replace(/^http/, "ws");
|
|
1260
1260
|
let c;
|
|
1261
1261
|
const a = this._httpClient.getCookieString(e);
|
|
1262
1262
|
let l = !1;
|
|
1263
1263
|
if (_.isNode || _.isReactNative) {
|
|
1264
|
-
const u = {}, [d,
|
|
1265
|
-
u[d] =
|
|
1264
|
+
const u = {}, [d, y] = I();
|
|
1265
|
+
u[d] = y, n && (u[k.Authorization] = `Bearer ${n}`), a && (u[k.Cookie] = a), c = new this._webSocketConstructor(e, void 0, {
|
|
1266
1266
|
headers: { ...u, ...this._headers }
|
|
1267
1267
|
});
|
|
1268
1268
|
} else
|
|
1269
1269
|
n && (e += (e.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(n)}`);
|
|
1270
1270
|
c || (c = new this._webSocketConstructor(e)), t === m.Binary && (c.binaryType = "arraybuffer"), c.onopen = (u) => {
|
|
1271
|
-
this._logger.log(
|
|
1271
|
+
this._logger.log(i.Information, `WebSocket connected to ${e}.`), this._webSocket = c, l = !0, o();
|
|
1272
1272
|
}, c.onerror = (u) => {
|
|
1273
1273
|
let d = null;
|
|
1274
|
-
typeof ErrorEvent < "u" && u instanceof ErrorEvent ? d = u.error : d = "There was an error with the transport", this._logger.log(
|
|
1274
|
+
typeof ErrorEvent < "u" && u instanceof ErrorEvent ? d = u.error : d = "There was an error with the transport", this._logger.log(i.Information, `(WebSockets transport) ${d}.`);
|
|
1275
1275
|
}, c.onmessage = (u) => {
|
|
1276
|
-
if (this._logger.log(
|
|
1276
|
+
if (this._logger.log(i.Trace, `(WebSockets transport) data received. ${R(u.data, this._logMessageContent)}.`), this.onreceive)
|
|
1277
1277
|
try {
|
|
1278
1278
|
this.onreceive(u.data);
|
|
1279
1279
|
} catch (d) {
|
|
@@ -1285,13 +1285,13 @@ class Ce {
|
|
|
1285
1285
|
this._close(u);
|
|
1286
1286
|
else {
|
|
1287
1287
|
let d = null;
|
|
1288
|
-
typeof ErrorEvent < "u" && u instanceof ErrorEvent ? d = u.error : d = "WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",
|
|
1288
|
+
typeof ErrorEvent < "u" && u instanceof ErrorEvent ? d = u.error : d = "WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.", r(new Error(d));
|
|
1289
1289
|
}
|
|
1290
1290
|
};
|
|
1291
1291
|
});
|
|
1292
1292
|
}
|
|
1293
1293
|
send(e) {
|
|
1294
|
-
return this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN ? (this._logger.log(
|
|
1294
|
+
return this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN ? (this._logger.log(i.Trace, `(WebSockets transport) sending data. ${R(e, this._logMessageContent)}.`), this._webSocket.send(e), Promise.resolve()) : Promise.reject("WebSocket is not in the OPEN state");
|
|
1295
1295
|
}
|
|
1296
1296
|
stop() {
|
|
1297
1297
|
return this._webSocket && this._close(void 0), Promise.resolve();
|
|
@@ -1300,7 +1300,7 @@ class Ce {
|
|
|
1300
1300
|
this._webSocket && (this._webSocket.onclose = () => {
|
|
1301
1301
|
}, this._webSocket.onmessage = () => {
|
|
1302
1302
|
}, this._webSocket.onerror = () => {
|
|
1303
|
-
}, this._webSocket.close(), this._webSocket = void 0), this._logger.log(
|
|
1303
|
+
}, this._webSocket.close(), this._webSocket = void 0), this._logger.log(i.Trace, "(WebSockets transport) socket closed."), this.onclose && (this._isCloseEvent(e) && (e.wasClean === !1 || e.code !== 1e3) ? this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason || "no reason given"}).`)) : e instanceof Error ? this.onclose(e) : this.onclose());
|
|
1304
1304
|
}
|
|
1305
1305
|
_isCloseEvent(e) {
|
|
1306
1306
|
return e && typeof e.wasClean == "boolean" && typeof e.code == "number";
|
|
@@ -1317,20 +1317,20 @@ class ve {
|
|
|
1317
1317
|
t.timeout = t.timeout === void 0 ? 100 * 1e3 : t.timeout;
|
|
1318
1318
|
let n = null, o = null;
|
|
1319
1319
|
if (_.isNode && typeof require < "u") {
|
|
1320
|
-
const
|
|
1321
|
-
n =
|
|
1320
|
+
const r = typeof __webpack_require__ == "function" ? __non_webpack_require__ : require;
|
|
1321
|
+
n = r("ws"), o = r("eventsource");
|
|
1322
1322
|
}
|
|
1323
1323
|
!_.isNode && typeof WebSocket < "u" && !t.WebSocket ? t.WebSocket = WebSocket : _.isNode && !t.WebSocket && n && (t.WebSocket = n), !_.isNode && typeof EventSource < "u" && !t.EventSource ? t.EventSource = EventSource : _.isNode && !t.EventSource && typeof o < "u" && (t.EventSource = o), this._httpClient = new be(t.httpClient || new he(this._logger), t.accessTokenFactory), this._connectionState = "Disconnected", this._connectionStarted = !1, this._options = t, this.onreceive = null, this.onclose = null;
|
|
1324
1324
|
}
|
|
1325
1325
|
async start(e) {
|
|
1326
|
-
if (e = e || m.Binary, p.isIn(e, m, "transferFormat"), this._logger.log(
|
|
1326
|
+
if (e = e || m.Binary, p.isIn(e, m, "transferFormat"), this._logger.log(i.Debug, `Starting connection with transfer format '${m[e]}'.`), this._connectionState !== "Disconnected")
|
|
1327
1327
|
return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));
|
|
1328
1328
|
if (this._connectionState = "Connecting", this._startInternalPromise = this._startInternal(e), await this._startInternalPromise, this._connectionState === "Disconnecting") {
|
|
1329
1329
|
const t = "Failed to start the HttpConnection before stop() was called.";
|
|
1330
|
-
return this._logger.log(
|
|
1330
|
+
return this._logger.log(i.Error, t), await this._stopPromise, Promise.reject(new b(t));
|
|
1331
1331
|
} else if (this._connectionState !== "Connected") {
|
|
1332
1332
|
const t = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
|
|
1333
|
-
return this._logger.log(
|
|
1333
|
+
return this._logger.log(i.Error, t), Promise.reject(new b(t));
|
|
1334
1334
|
}
|
|
1335
1335
|
this._connectionStarted = !0;
|
|
1336
1336
|
}
|
|
@@ -1339,9 +1339,9 @@ class ve {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
async stop(e) {
|
|
1341
1341
|
if (this._connectionState === "Disconnected")
|
|
1342
|
-
return this._logger.log(
|
|
1342
|
+
return this._logger.log(i.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`), Promise.resolve();
|
|
1343
1343
|
if (this._connectionState === "Disconnecting")
|
|
1344
|
-
return this._logger.log(
|
|
1344
|
+
return this._logger.log(i.Debug, `Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`), this._stopPromise;
|
|
1345
1345
|
this._connectionState = "Disconnecting", this._stopPromise = new Promise((t) => {
|
|
1346
1346
|
this._stopPromiseResolver = t;
|
|
1347
1347
|
}), await this._stopInternal(e), await this._stopPromise;
|
|
@@ -1356,11 +1356,11 @@ class ve {
|
|
|
1356
1356
|
try {
|
|
1357
1357
|
await this.transport.stop();
|
|
1358
1358
|
} catch (t) {
|
|
1359
|
-
this._logger.log(
|
|
1359
|
+
this._logger.log(i.Error, `HttpConnection.transport.stop() threw error '${t}'.`), this._stopConnection();
|
|
1360
1360
|
}
|
|
1361
1361
|
this.transport = void 0;
|
|
1362
1362
|
} else
|
|
1363
|
-
this._logger.log(
|
|
1363
|
+
this._logger.log(i.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
|
|
1364
1364
|
}
|
|
1365
1365
|
async _startInternal(e) {
|
|
1366
1366
|
let t = this.baseUrl;
|
|
@@ -1375,14 +1375,14 @@ class ve {
|
|
|
1375
1375
|
let n = null, o = 0;
|
|
1376
1376
|
do {
|
|
1377
1377
|
if (n = await this._getNegotiationResponse(t), this._connectionState === "Disconnecting" || this._connectionState === "Disconnected")
|
|
1378
|
-
throw new
|
|
1378
|
+
throw new b("The connection was stopped during negotiation.");
|
|
1379
1379
|
if (n.error)
|
|
1380
1380
|
throw new Error(n.error);
|
|
1381
1381
|
if (n.ProtocolVersion)
|
|
1382
1382
|
throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
|
|
1383
1383
|
if (n.url && (t = n.url), n.accessToken) {
|
|
1384
|
-
const
|
|
1385
|
-
this._accessTokenFactory = () =>
|
|
1384
|
+
const r = n.accessToken;
|
|
1385
|
+
this._accessTokenFactory = () => r, this._httpClient._accessToken = r, this._httpClient._accessTokenFactory = void 0;
|
|
1386
1386
|
}
|
|
1387
1387
|
o++;
|
|
1388
1388
|
} while (n.url && o < O);
|
|
@@ -1390,18 +1390,18 @@ class ve {
|
|
|
1390
1390
|
throw new Error("Negotiate redirection limit exceeded.");
|
|
1391
1391
|
await this._createTransport(t, this._options.transport, n, e);
|
|
1392
1392
|
}
|
|
1393
|
-
this.transport instanceof j && (this.features.inherentKeepAlive = !0), this._connectionState === "Connecting" && (this._logger.log(
|
|
1393
|
+
this.transport instanceof j && (this.features.inherentKeepAlive = !0), this._connectionState === "Connecting" && (this._logger.log(i.Debug, "The HttpConnection connected successfully."), this._connectionState = "Connected");
|
|
1394
1394
|
} catch (n) {
|
|
1395
|
-
return this._logger.log(
|
|
1395
|
+
return this._logger.log(i.Error, "Failed to start the connection: " + n), this._connectionState = "Disconnected", this.transport = void 0, this._stopPromiseResolver(), Promise.reject(n);
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
1398
|
async _getNegotiationResponse(e) {
|
|
1399
|
-
const t = {}, [n, o] =
|
|
1399
|
+
const t = {}, [n, o] = I();
|
|
1400
1400
|
t[n] = o;
|
|
1401
|
-
const
|
|
1402
|
-
this._logger.log(
|
|
1401
|
+
const r = this._resolveNegotiateUrl(e);
|
|
1402
|
+
this._logger.log(i.Debug, `Sending negotiation request: ${r}.`);
|
|
1403
1403
|
try {
|
|
1404
|
-
const c = await this._httpClient.post(
|
|
1404
|
+
const c = await this._httpClient.post(r, {
|
|
1405
1405
|
content: "",
|
|
1406
1406
|
headers: { ...t, ...this._options.headers },
|
|
1407
1407
|
timeout: this._options.timeout,
|
|
@@ -1413,16 +1413,16 @@ class ve {
|
|
|
1413
1413
|
return (!a.negotiateVersion || a.negotiateVersion < 1) && (a.connectionToken = a.connectionId), a.useStatefulReconnect && this._options._useStatefulReconnect !== !0 ? Promise.reject(new U("Client didn't negotiate Stateful Reconnect but the server did.")) : a;
|
|
1414
1414
|
} catch (c) {
|
|
1415
1415
|
let a = "Failed to complete negotiation with the server: " + c;
|
|
1416
|
-
return c instanceof
|
|
1416
|
+
return c instanceof v && c.statusCode === 404 && (a = a + " Either this is not a SignalR endpoint or there is a proxy blocking the connection."), this._logger.log(i.Error, a), Promise.reject(new U(a));
|
|
1417
1417
|
}
|
|
1418
1418
|
}
|
|
1419
1419
|
_createConnectUrl(e, t) {
|
|
1420
1420
|
return t ? e + (e.indexOf("?") === -1 ? "?" : "&") + `id=${t}` : e;
|
|
1421
1421
|
}
|
|
1422
1422
|
async _createTransport(e, t, n, o) {
|
|
1423
|
-
let
|
|
1423
|
+
let r = this._createConnectUrl(e, n.connectionToken);
|
|
1424
1424
|
if (this._isITransport(t)) {
|
|
1425
|
-
this._logger.log(
|
|
1425
|
+
this._logger.log(i.Debug, "Connection was provided an instance of ITransport, using that directly."), this.transport = t, await this._startTransport(r, o), this.connectionId = n.connectionId;
|
|
1426
1426
|
return;
|
|
1427
1427
|
}
|
|
1428
1428
|
const c = [], a = n.availableTransports || [];
|
|
@@ -1435,18 +1435,18 @@ class ve {
|
|
|
1435
1435
|
if (this.transport = d, !l) {
|
|
1436
1436
|
try {
|
|
1437
1437
|
l = await this._getNegotiationResponse(e);
|
|
1438
|
-
} catch (
|
|
1439
|
-
return Promise.reject(
|
|
1438
|
+
} catch (y) {
|
|
1439
|
+
return Promise.reject(y);
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1441
|
+
r = this._createConnectUrl(e, l.connectionToken);
|
|
1442
1442
|
}
|
|
1443
1443
|
try {
|
|
1444
|
-
await this._startTransport(
|
|
1444
|
+
await this._startTransport(r, o), this.connectionId = l.connectionId;
|
|
1445
1445
|
return;
|
|
1446
|
-
} catch (
|
|
1447
|
-
if (this._logger.log(
|
|
1446
|
+
} catch (y) {
|
|
1447
|
+
if (this._logger.log(i.Error, `Failed to start the transport '${u.transport}': ${y}`), l = void 0, c.push(new Q(`${u.transport} failed: ${y}`, f[u.transport])), this._connectionState !== "Connecting") {
|
|
1448
1448
|
const W = "Failed to select transport before stop() was called.";
|
|
1449
|
-
return this._logger.log(
|
|
1449
|
+
return this._logger.log(i.Debug, W), Promise.reject(new b(W));
|
|
1450
1450
|
}
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
@@ -1458,11 +1458,11 @@ class ve {
|
|
|
1458
1458
|
case f.WebSockets:
|
|
1459
1459
|
if (!this._options.WebSocket)
|
|
1460
1460
|
throw new Error("'WebSocket' is not supported in your environment.");
|
|
1461
|
-
return new
|
|
1461
|
+
return new ye(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});
|
|
1462
1462
|
case f.ServerSentEvents:
|
|
1463
1463
|
if (!this._options.EventSource)
|
|
1464
1464
|
throw new Error("'EventSource' is not supported in your environment.");
|
|
1465
|
-
return new
|
|
1465
|
+
return new Ce(this._httpClient, this._httpClient._accessToken, this._logger, this._options);
|
|
1466
1466
|
case f.LongPolling:
|
|
1467
1467
|
return new j(this._httpClient, this._logger, this._options);
|
|
1468
1468
|
default:
|
|
@@ -1486,42 +1486,42 @@ class ve {
|
|
|
1486
1486
|
} : this.transport.onclose = (n) => this._stopConnection(n), this.transport.connect(e, t);
|
|
1487
1487
|
}
|
|
1488
1488
|
_resolveTransportOrError(e, t, n, o) {
|
|
1489
|
-
const
|
|
1490
|
-
if (
|
|
1491
|
-
return this._logger.log(
|
|
1492
|
-
if (ke(t,
|
|
1489
|
+
const r = f[e.transport];
|
|
1490
|
+
if (r == null)
|
|
1491
|
+
return this._logger.log(i.Debug, `Skipping transport '${e.transport}' because it is not supported by this client.`), new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);
|
|
1492
|
+
if (ke(t, r))
|
|
1493
1493
|
if (e.transferFormats.map((a) => m[a]).indexOf(n) >= 0) {
|
|
1494
|
-
if (
|
|
1495
|
-
return this._logger.log(
|
|
1496
|
-
this._logger.log(
|
|
1494
|
+
if (r === f.WebSockets && !this._options.WebSocket || r === f.ServerSentEvents && !this._options.EventSource)
|
|
1495
|
+
return this._logger.log(i.Debug, `Skipping transport '${f[r]}' because it is not supported in your environment.'`), new V(`'${f[r]}' is not supported in your environment.`, r);
|
|
1496
|
+
this._logger.log(i.Debug, `Selecting transport '${f[r]}'.`);
|
|
1497
1497
|
try {
|
|
1498
|
-
return this.features.reconnect =
|
|
1498
|
+
return this.features.reconnect = r === f.WebSockets ? o : void 0, this._constructTransport(r);
|
|
1499
1499
|
} catch (a) {
|
|
1500
1500
|
return a;
|
|
1501
1501
|
}
|
|
1502
1502
|
} else
|
|
1503
|
-
return this._logger.log(
|
|
1503
|
+
return this._logger.log(i.Debug, `Skipping transport '${f[r]}' because it does not support the requested transfer format '${m[n]}'.`), new Error(`'${f[r]}' does not support ${m[n]}.`);
|
|
1504
1504
|
else
|
|
1505
|
-
return this._logger.log(
|
|
1505
|
+
return this._logger.log(i.Debug, `Skipping transport '${f[r]}' because it was disabled by the client.`), new G(`'${f[r]}' is disabled by the client.`, r);
|
|
1506
1506
|
}
|
|
1507
1507
|
_isITransport(e) {
|
|
1508
1508
|
return e && typeof e == "object" && "connect" in e;
|
|
1509
1509
|
}
|
|
1510
1510
|
_stopConnection(e) {
|
|
1511
|
-
if (this._logger.log(
|
|
1512
|
-
this._logger.log(
|
|
1511
|
+
if (this._logger.log(i.Debug, `HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`), this.transport = void 0, e = this._stopError || e, this._stopError = void 0, this._connectionState === "Disconnected") {
|
|
1512
|
+
this._logger.log(i.Debug, `Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`);
|
|
1513
1513
|
return;
|
|
1514
1514
|
}
|
|
1515
1515
|
if (this._connectionState === "Connecting")
|
|
1516
|
-
throw this._logger.log(
|
|
1517
|
-
if (this._connectionState === "Disconnecting" && this._stopPromiseResolver(), e ? this._logger.log(
|
|
1518
|
-
this._logger.log(
|
|
1516
|
+
throw this._logger.log(i.Warning, `Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`), new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);
|
|
1517
|
+
if (this._connectionState === "Disconnecting" && this._stopPromiseResolver(), e ? this._logger.log(i.Error, `Connection disconnected with error '${e}'.`) : this._logger.log(i.Information, "Connection disconnected."), this._sendQueue && (this._sendQueue.stop().catch((t) => {
|
|
1518
|
+
this._logger.log(i.Error, `TransportSendQueue.stop() threw error '${t}'.`);
|
|
1519
1519
|
}), this._sendQueue = void 0), this.connectionId = void 0, this._connectionState = "Disconnected", this._connectionStarted) {
|
|
1520
1520
|
this._connectionStarted = !1;
|
|
1521
1521
|
try {
|
|
1522
1522
|
this.onclose && this.onclose(e);
|
|
1523
1523
|
} catch (t) {
|
|
1524
|
-
this._logger.log(
|
|
1524
|
+
this._logger.log(i.Error, `HttpConnection.onclose(${e}) threw error '${t}'.`);
|
|
1525
1525
|
}
|
|
1526
1526
|
}
|
|
1527
1527
|
}
|
|
@@ -1531,7 +1531,7 @@ class ve {
|
|
|
1531
1531
|
if (!_.isBrowser)
|
|
1532
1532
|
throw new Error(`Cannot resolve '${e}'.`);
|
|
1533
1533
|
const t = window.document.createElement("a");
|
|
1534
|
-
return t.href = e, this._logger.log(
|
|
1534
|
+
return t.href = e, this._logger.log(i.Information, `Normalizing '${e}' to '${t.href}'.`), t.href;
|
|
1535
1535
|
}
|
|
1536
1536
|
_resolveNegotiateUrl(e) {
|
|
1537
1537
|
const t = new URL(e);
|
|
@@ -1577,10 +1577,10 @@ class N {
|
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
1579
|
static _concatBuffers(e) {
|
|
1580
|
-
const t = e.map((
|
|
1580
|
+
const t = e.map((r) => r.byteLength).reduce((r, c) => r + c), n = new Uint8Array(t);
|
|
1581
1581
|
let o = 0;
|
|
1582
|
-
for (const
|
|
1583
|
-
n.set(new Uint8Array(
|
|
1582
|
+
for (const r of e)
|
|
1583
|
+
n.set(new Uint8Array(r), o), o += r.byteLength;
|
|
1584
1584
|
return n.buffer;
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
@@ -1611,9 +1611,9 @@ class Ie {
|
|
|
1611
1611
|
if (!e)
|
|
1612
1612
|
return [];
|
|
1613
1613
|
t === null && (t = P.instance);
|
|
1614
|
-
const n =
|
|
1615
|
-
for (const
|
|
1616
|
-
const c = JSON.parse(
|
|
1614
|
+
const n = w.parse(e), o = [];
|
|
1615
|
+
for (const r of n) {
|
|
1616
|
+
const c = JSON.parse(r);
|
|
1617
1617
|
if (typeof c.type != "number")
|
|
1618
1618
|
throw new Error("Invalid payload.");
|
|
1619
1619
|
switch (c.type) {
|
|
@@ -1637,7 +1637,7 @@ class Ie {
|
|
|
1637
1637
|
this._isSequenceMessage(c);
|
|
1638
1638
|
break;
|
|
1639
1639
|
default:
|
|
1640
|
-
t.log(
|
|
1640
|
+
t.log(i.Information, "Unknown message type '" + c.type + "' ignored.");
|
|
1641
1641
|
continue;
|
|
1642
1642
|
}
|
|
1643
1643
|
o.push(c);
|
|
@@ -1650,7 +1650,7 @@ class Ie {
|
|
|
1650
1650
|
* @returns {string} A string containing the serialized representation of the message.
|
|
1651
1651
|
*/
|
|
1652
1652
|
writeMessage(e) {
|
|
1653
|
-
return
|
|
1653
|
+
return w.write(JSON.stringify(e));
|
|
1654
1654
|
}
|
|
1655
1655
|
_isInvocationMessage(e) {
|
|
1656
1656
|
this._assertNotEmptyString(e.target, "Invalid payload for Invocation message."), e.invocationId !== void 0 && this._assertNotEmptyString(e.invocationId, "Invalid payload for Invocation message.");
|
|
@@ -1678,15 +1678,15 @@ class Ie {
|
|
|
1678
1678
|
}
|
|
1679
1679
|
}
|
|
1680
1680
|
const Te = {
|
|
1681
|
-
trace:
|
|
1682
|
-
debug:
|
|
1683
|
-
info:
|
|
1684
|
-
information:
|
|
1685
|
-
warn:
|
|
1686
|
-
warning:
|
|
1687
|
-
error:
|
|
1688
|
-
critical:
|
|
1689
|
-
none:
|
|
1681
|
+
trace: i.Trace,
|
|
1682
|
+
debug: i.Debug,
|
|
1683
|
+
info: i.Information,
|
|
1684
|
+
information: i.Information,
|
|
1685
|
+
warn: i.Warning,
|
|
1686
|
+
warning: i.Warning,
|
|
1687
|
+
error: i.Error,
|
|
1688
|
+
critical: i.Critical,
|
|
1689
|
+
none: i.None
|
|
1690
1690
|
};
|
|
1691
1691
|
function Pe(s) {
|
|
1692
1692
|
const e = Te[s.toLowerCase()];
|
|
@@ -1721,7 +1721,7 @@ class Re {
|
|
|
1721
1721
|
withAutomaticReconnect(e) {
|
|
1722
1722
|
if (this.reconnectPolicy)
|
|
1723
1723
|
throw new Error("A reconnectPolicy has already been set.");
|
|
1724
|
-
return e ? Array.isArray(e) ? this.reconnectPolicy = new
|
|
1724
|
+
return e ? Array.isArray(e) ? this.reconnectPolicy = new L(e) : this.reconnectPolicy = e : this.reconnectPolicy = new L(), this;
|
|
1725
1725
|
}
|
|
1726
1726
|
/** Configures {@link @microsoft/signalr.HubConnection.serverTimeoutInMilliseconds} for the {@link @microsoft/signalr.HubConnection}.
|
|
1727
1727
|
*
|
|
@@ -1759,14 +1759,14 @@ class Re {
|
|
|
1759
1759
|
function $e(s) {
|
|
1760
1760
|
return s.log !== void 0;
|
|
1761
1761
|
}
|
|
1762
|
-
var De = Object.defineProperty, xe = Object.getOwnPropertyDescriptor,
|
|
1763
|
-
for (var o = n > 1 ? void 0 : n ? xe(e, t) : e,
|
|
1764
|
-
(c = s[
|
|
1762
|
+
var De = Object.defineProperty, xe = Object.getOwnPropertyDescriptor, C = (s, e, t, n) => {
|
|
1763
|
+
for (var o = n > 1 ? void 0 : n ? xe(e, t) : e, r = s.length - 1, c; r >= 0; r--)
|
|
1764
|
+
(c = s[r]) && (o = (n ? c(e, t, o) : c(o)) || o);
|
|
1765
1765
|
return n && o && De(e, t, o), o;
|
|
1766
1766
|
};
|
|
1767
|
-
let
|
|
1767
|
+
let S = class extends K {
|
|
1768
1768
|
constructor() {
|
|
1769
|
-
super(...arguments), this.connection = null, this.watchedMethods = /* @__PURE__ */ new Set(), this.baseUrl = "", this.keepAliveIntervalInMilliseconds = 15e3, this.serverTimeoutInMilliseconds = 3e4, this.skipNegotiation = !1, this.
|
|
1769
|
+
super(...arguments), this.connection = null, this.watchedMethods = /* @__PURE__ */ new Set(), this.baseUrl = "", this.keepAliveIntervalInMilliseconds = 15e3, this.serverTimeoutInMilliseconds = 3e4, this.skipNegotiation = !1, this.transport = f.WebSockets, this.connectMode = "manual", this.emitEvent = (s, e) => {
|
|
1770
1770
|
this.emit(s, {
|
|
1771
1771
|
detail: {
|
|
1772
1772
|
args: e
|
|
@@ -1778,33 +1778,12 @@ let w = class extends K {
|
|
|
1778
1778
|
super.connectedCallback();
|
|
1779
1779
|
const s = this.addEventListener;
|
|
1780
1780
|
this.addEventListener = (e, t, ...n) => {
|
|
1781
|
-
const [o,
|
|
1782
|
-
o === "cx-invoked" && (this.watchedMethods.add(
|
|
1783
|
-
this.emitEvent(`cx-invoked.${
|
|
1781
|
+
const [o, r] = e.split(".");
|
|
1782
|
+
o === "cx-invoked" && (this.watchedMethods.add(r), this.connection?.on(r, (...c) => {
|
|
1783
|
+
this.emitEvent(`cx-invoked.${r}`, c);
|
|
1784
1784
|
})), s.call(this, e, t, ...n);
|
|
1785
1785
|
}, this.connectMode === "auto" && this.start();
|
|
1786
1786
|
}
|
|
1787
|
-
registerConnectionLifecycleListeners() {
|
|
1788
|
-
this.connection && (this.connection.onreconnecting((s) => {
|
|
1789
|
-
this.emit("cx-hub-connection-reconnecting", {
|
|
1790
|
-
detail: {
|
|
1791
|
-
error: s
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
}), this.connection.onreconnected((s) => {
|
|
1795
|
-
this.emit("cx-hub-connection-reconnected", {
|
|
1796
|
-
detail: {
|
|
1797
|
-
connectionId: s
|
|
1798
|
-
}
|
|
1799
|
-
});
|
|
1800
|
-
}), this.connection.onclose((s) => {
|
|
1801
|
-
this.emit("cx-hub-connection-disconnected", {
|
|
1802
|
-
detail: {
|
|
1803
|
-
error: s
|
|
1804
|
-
}
|
|
1805
|
-
});
|
|
1806
|
-
}));
|
|
1807
|
-
}
|
|
1808
1787
|
registerEventListeners() {
|
|
1809
1788
|
this.connection && this.watchedMethods.forEach((s) => {
|
|
1810
1789
|
this.connection?.on(
|
|
@@ -1816,27 +1795,14 @@ let w = class extends K {
|
|
|
1816
1795
|
onBaseUrlChanged() {
|
|
1817
1796
|
this.connectMode === "auto" && this.start();
|
|
1818
1797
|
}
|
|
1819
|
-
configureAutomaticReconnect(s) {
|
|
1820
|
-
return this.withAutomaticReconnect ? this.automaticReconnectRetryPolicy ? s.withAutomaticReconnect(
|
|
1821
|
-
this.automaticReconnectRetryPolicy
|
|
1822
|
-
) : this.automaticReconnectRetryDelays && this.automaticReconnectRetryDelays.length > 0 ? s.withAutomaticReconnect(
|
|
1823
|
-
this.automaticReconnectRetryDelays
|
|
1824
|
-
) : s.withAutomaticReconnect() : s;
|
|
1825
|
-
}
|
|
1826
1798
|
/** Starts the connection.
|
|
1827
1799
|
* @returns A Promise that resolves when the connection is successfully started, or rejects with an error.
|
|
1828
1800
|
*/
|
|
1829
1801
|
async start() {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
{
|
|
1835
|
-
skipNegotiation: this.skipNegotiation,
|
|
1836
|
-
transport: this.transport
|
|
1837
|
-
}
|
|
1838
|
-
);
|
|
1839
|
-
s = this.configureAutomaticReconnect(s), this.connection = s.withKeepAliveInterval(this.keepAliveIntervalInMilliseconds).withServerTimeout(this.serverTimeoutInMilliseconds).build(), this.registerEventListeners(), this.registerConnectionLifecycleListeners(), await this.connection.start();
|
|
1802
|
+
this.connection && await this.stop(), this.baseUrl && (this.connection = new Re().withUrl(this.baseUrl, {
|
|
1803
|
+
skipNegotiation: this.skipNegotiation,
|
|
1804
|
+
transport: this.transport
|
|
1805
|
+
}).withKeepAliveInterval(this.keepAliveIntervalInMilliseconds).withServerTimeout(this.serverTimeoutInMilliseconds).build(), this.registerEventListeners(), await this.connection.start());
|
|
1840
1806
|
}
|
|
1841
1807
|
/** Stops the connection.
|
|
1842
1808
|
* @returns A Promise that resolves when the connection is successfully stopped, or rejects with an error.
|
|
@@ -1858,65 +1824,53 @@ let w = class extends K {
|
|
|
1858
1824
|
return await this.connection.invoke(s, ...e);
|
|
1859
1825
|
}
|
|
1860
1826
|
};
|
|
1861
|
-
|
|
1827
|
+
C([
|
|
1862
1828
|
F()
|
|
1863
|
-
],
|
|
1864
|
-
|
|
1829
|
+
], S.prototype, "connection", 2);
|
|
1830
|
+
C([
|
|
1865
1831
|
F()
|
|
1866
|
-
],
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
],
|
|
1870
|
-
|
|
1871
|
-
|
|
1832
|
+
], S.prototype, "watchedMethods", 2);
|
|
1833
|
+
C([
|
|
1834
|
+
T({ attribute: "base-url", reflect: !0, type: String })
|
|
1835
|
+
], S.prototype, "baseUrl", 2);
|
|
1836
|
+
C([
|
|
1837
|
+
T({
|
|
1872
1838
|
attribute: "keep-alive-interval-in-milliseconds",
|
|
1873
1839
|
reflect: !0,
|
|
1874
1840
|
type: Number
|
|
1875
1841
|
})
|
|
1876
|
-
],
|
|
1877
|
-
|
|
1878
|
-
|
|
1842
|
+
], S.prototype, "keepAliveIntervalInMilliseconds", 2);
|
|
1843
|
+
C([
|
|
1844
|
+
T({
|
|
1879
1845
|
attribute: "server-timeout-in-milliseconds",
|
|
1880
1846
|
reflect: !0,
|
|
1881
1847
|
type: Number
|
|
1882
1848
|
})
|
|
1883
|
-
],
|
|
1884
|
-
|
|
1885
|
-
|
|
1849
|
+
], S.prototype, "serverTimeoutInMilliseconds", 2);
|
|
1850
|
+
C([
|
|
1851
|
+
T({
|
|
1886
1852
|
attribute: "skip-negotiation",
|
|
1887
1853
|
type: Boolean
|
|
1888
1854
|
})
|
|
1889
|
-
],
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
attribute: "with-automatic-reconnect",
|
|
1893
|
-
type: Boolean
|
|
1894
|
-
})
|
|
1895
|
-
], w.prototype, "withAutomaticReconnect", 2);
|
|
1896
|
-
S([
|
|
1897
|
-
v({ attribute: !1, type: Array })
|
|
1898
|
-
], w.prototype, "automaticReconnectRetryDelays", 2);
|
|
1899
|
-
S([
|
|
1900
|
-
v({ attribute: !1, type: Object })
|
|
1901
|
-
], w.prototype, "automaticReconnectRetryPolicy", 2);
|
|
1902
|
-
S([
|
|
1903
|
-
v({
|
|
1855
|
+
], S.prototype, "skipNegotiation", 2);
|
|
1856
|
+
C([
|
|
1857
|
+
T({
|
|
1904
1858
|
type: Number
|
|
1905
1859
|
})
|
|
1906
|
-
],
|
|
1907
|
-
|
|
1908
|
-
|
|
1860
|
+
], S.prototype, "transport", 2);
|
|
1861
|
+
C([
|
|
1862
|
+
T({
|
|
1909
1863
|
attribute: "connect-mode"
|
|
1910
1864
|
})
|
|
1911
|
-
],
|
|
1912
|
-
|
|
1865
|
+
], S.prototype, "connectMode", 2);
|
|
1866
|
+
C([
|
|
1913
1867
|
J("baseUrl")
|
|
1914
|
-
],
|
|
1915
|
-
|
|
1868
|
+
], S.prototype, "onBaseUrlChanged", 1);
|
|
1869
|
+
S = C([
|
|
1916
1870
|
X("cx-hub-connection")
|
|
1917
|
-
],
|
|
1871
|
+
], S);
|
|
1918
1872
|
export {
|
|
1919
|
-
|
|
1873
|
+
S as C,
|
|
1920
1874
|
Re as H,
|
|
1921
1875
|
f as a
|
|
1922
1876
|
};
|