@sparkle-learning/core 0.0.51 → 0.0.53
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/header-mobile-collapse_61.cjs.entry.js +16 -2995
- package/dist/cjs/{ion-select_2.cjs.entry.js → ion-select_3.cjs.entry.js} +118 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/signalR.service-5672eebc.js +2987 -0
- package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -0
- package/dist/cjs/sparkle-core.cjs.js +1 -1
- package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +272 -0
- package/dist/cjs/sparkle-discussion.cjs.entry.js +40 -0
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/sparkle-animation-player/sparkle-animation-player.js +1 -0
- package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +1 -1
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.css +157 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +230 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.css +158 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +268 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +0 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +110 -0
- package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.css +16 -0
- package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +17 -13
- package/dist/esm/header-mobile-collapse_61.entry.js +4 -2983
- package/dist/esm/{ion-select_2.entry.js → ion-select_3.entry.js} +118 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/signalR.service-9d5b9f36.js +2984 -0
- package/dist/esm/sparkle-animation-player.entry.js +1 -0
- package/dist/esm/sparkle-core.js +1 -1
- package/dist/esm/sparkle-discussion-questions_2.entry.js +267 -0
- package/dist/esm/sparkle-discussion.entry.js +36 -0
- package/dist/node_modules/@sparkle-learning/components/dist/collection/components/page-footer/page-footer.css +7 -0
- package/dist/sparkle-core/{p-31be4dc4.entry.js → p-0a5d7c4f.entry.js} +26 -26
- package/dist/sparkle-core/p-18cdd458.entry.js +1 -0
- package/dist/sparkle-core/p-30767c1c.entry.js +1 -0
- package/dist/sparkle-core/p-3265ed87.entry.js +1 -0
- package/dist/sparkle-core/{p-564e64fc.entry.js → p-44334ef3.entry.js} +2 -2
- package/dist/sparkle-core/p-4c9f994f.js +1 -0
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- package/dist/types/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.d.ts +28 -0
- package/dist/types/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.d.ts +45 -0
- package/dist/types/components/sparkle-discussion/sparkle-discussion.d.ts +11 -0
- package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +1 -0
- package/dist/types/components.d.ts +66 -1
- package/package.json +6 -6
- package/dist/cjs/sparkle-feed-post.cjs.entry.js +0 -120
- package/dist/esm/sparkle-feed-post.entry.js +0 -116
- package/dist/sparkle-core/p-41a9ece7.entry.js +0 -1
- package/dist/sparkle-core/p-e77d982d.entry.js +0 -1
- package/dist/types/components/sparkle-quiz/sparkle-quiz.d.ts +0 -41
@@ -11,13 +11,14 @@ import { S as SPINNERS } from './spinner-configs-a37e628a.js';
|
|
11
11
|
import { A as ActiveRouter } from './active-router-fc9e4e06.js';
|
12
12
|
import { i as initSetupConfig, A as AuthService, P as PrivateRoute, s as setupConfig } from './PrivateRoute-c5441f35.js';
|
13
13
|
import { A as AssetsService } from './assets.service-66e848b8.js';
|
14
|
-
import { A as AuthStore, c as createCommonjsModule, g as getDefaultExportFromCjs, b as commonjsGlobal,
|
14
|
+
import { A as AuthStore, c as createCommonjsModule, g as getDefaultExportFromCjs, b as commonjsGlobal, T as TocStore, d as createStore } from './auth.store-dba2c2da.js';
|
15
15
|
import { u as userStore, S as StudentService } from './student.service-0746418b.js';
|
16
16
|
import { E as EnvironmentConfigService } from './environment-config.service-2b5d692b.js';
|
17
17
|
import { s as sample, S as SparkleGlobal$1, d as date, M as MyHealthTemplate, a as MyHealthTemplateJSON, b as MyMoodTemplate, c as MyMoodTemplateJSON } from './util-6ef753e9.js';
|
18
18
|
import { F as FacilitatorService, f as facilitatorStore } from './facilitator.service-b0292f7f.js';
|
19
19
|
import { m as menuController } from './index-cded2d87.js';
|
20
20
|
import { m as modalController, a as alertController, t as toastController } from './overlays-3b4dca92.js';
|
21
|
+
import { S as SignalRService, s as signalRStore } from './signalR.service-9d5b9f36.js';
|
21
22
|
import { H as HttpService } from './httpService-7b75b095.js';
|
22
23
|
import { A as AppDataService, g as goalStore, F as FeedService, f as feedStore } from './feed.service-8fbe4ce3.js';
|
23
24
|
import './localstorage.service-4bf408c8.js';
|
@@ -3064,7 +3065,7 @@ const SparkleCourseRoot = class {
|
|
3064
3065
|
this.config = {
|
3065
3066
|
appUrl: 'http://localhost:3333',
|
3066
3067
|
globalAssetsUrl: 'http://localhost:3333/assets',
|
3067
|
-
apiUrl: 'https://localhost:
|
3068
|
+
apiUrl: 'https://localhost:44399/',
|
3068
3069
|
quizPath: this.quizPath,
|
3069
3070
|
tocPath: this.tocPath,
|
3070
3071
|
menu: {
|
@@ -12455,2986 +12456,6 @@ const FacilitatorNotes = class {
|
|
12455
12456
|
};
|
12456
12457
|
FacilitatorNotes.style = facilitatorNotesCss;
|
12457
12458
|
|
12458
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12459
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
12460
|
-
/** Error thrown when an HTTP request fails. */
|
12461
|
-
class HttpError extends Error {
|
12462
|
-
/** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
|
12463
|
-
*
|
12464
|
-
* @param {string} errorMessage A descriptive error message.
|
12465
|
-
* @param {number} statusCode The HTTP status code represented by this error.
|
12466
|
-
*/
|
12467
|
-
constructor(errorMessage, statusCode) {
|
12468
|
-
const trueProto = new.target.prototype;
|
12469
|
-
super(`${errorMessage}: Status code '${statusCode}'`);
|
12470
|
-
this.statusCode = statusCode;
|
12471
|
-
// Workaround issue in Typescript compiler
|
12472
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12473
|
-
this.__proto__ = trueProto;
|
12474
|
-
}
|
12475
|
-
}
|
12476
|
-
/** Error thrown when a timeout elapses. */
|
12477
|
-
class TimeoutError extends Error {
|
12478
|
-
/** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
|
12479
|
-
*
|
12480
|
-
* @param {string} errorMessage A descriptive error message.
|
12481
|
-
*/
|
12482
|
-
constructor(errorMessage = "A timeout occurred.") {
|
12483
|
-
const trueProto = new.target.prototype;
|
12484
|
-
super(errorMessage);
|
12485
|
-
// Workaround issue in Typescript compiler
|
12486
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12487
|
-
this.__proto__ = trueProto;
|
12488
|
-
}
|
12489
|
-
}
|
12490
|
-
/** Error thrown when an action is aborted. */
|
12491
|
-
class AbortError extends Error {
|
12492
|
-
/** Constructs a new instance of {@link AbortError}.
|
12493
|
-
*
|
12494
|
-
* @param {string} errorMessage A descriptive error message.
|
12495
|
-
*/
|
12496
|
-
constructor(errorMessage = "An abort occurred.") {
|
12497
|
-
const trueProto = new.target.prototype;
|
12498
|
-
super(errorMessage);
|
12499
|
-
// Workaround issue in Typescript compiler
|
12500
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12501
|
-
this.__proto__ = trueProto;
|
12502
|
-
}
|
12503
|
-
}
|
12504
|
-
/** Error thrown when the selected transport is unsupported by the browser. */
|
12505
|
-
/** @private */
|
12506
|
-
class UnsupportedTransportError extends Error {
|
12507
|
-
/** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
|
12508
|
-
*
|
12509
|
-
* @param {string} message A descriptive error message.
|
12510
|
-
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
|
12511
|
-
*/
|
12512
|
-
constructor(message, transport) {
|
12513
|
-
const trueProto = new.target.prototype;
|
12514
|
-
super(message);
|
12515
|
-
this.transport = transport;
|
12516
|
-
this.errorType = 'UnsupportedTransportError';
|
12517
|
-
// Workaround issue in Typescript compiler
|
12518
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12519
|
-
this.__proto__ = trueProto;
|
12520
|
-
}
|
12521
|
-
}
|
12522
|
-
/** Error thrown when the selected transport is disabled by the browser. */
|
12523
|
-
/** @private */
|
12524
|
-
class DisabledTransportError extends Error {
|
12525
|
-
/** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
|
12526
|
-
*
|
12527
|
-
* @param {string} message A descriptive error message.
|
12528
|
-
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
|
12529
|
-
*/
|
12530
|
-
constructor(message, transport) {
|
12531
|
-
const trueProto = new.target.prototype;
|
12532
|
-
super(message);
|
12533
|
-
this.transport = transport;
|
12534
|
-
this.errorType = 'DisabledTransportError';
|
12535
|
-
// Workaround issue in Typescript compiler
|
12536
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12537
|
-
this.__proto__ = trueProto;
|
12538
|
-
}
|
12539
|
-
}
|
12540
|
-
/** Error thrown when the selected transport cannot be started. */
|
12541
|
-
/** @private */
|
12542
|
-
class FailedToStartTransportError extends Error {
|
12543
|
-
/** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
|
12544
|
-
*
|
12545
|
-
* @param {string} message A descriptive error message.
|
12546
|
-
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
|
12547
|
-
*/
|
12548
|
-
constructor(message, transport) {
|
12549
|
-
const trueProto = new.target.prototype;
|
12550
|
-
super(message);
|
12551
|
-
this.transport = transport;
|
12552
|
-
this.errorType = 'FailedToStartTransportError';
|
12553
|
-
// Workaround issue in Typescript compiler
|
12554
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12555
|
-
this.__proto__ = trueProto;
|
12556
|
-
}
|
12557
|
-
}
|
12558
|
-
/** Error thrown when the negotiation with the server failed to complete. */
|
12559
|
-
/** @private */
|
12560
|
-
class FailedToNegotiateWithServerError extends Error {
|
12561
|
-
/** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
|
12562
|
-
*
|
12563
|
-
* @param {string} message A descriptive error message.
|
12564
|
-
*/
|
12565
|
-
constructor(message) {
|
12566
|
-
const trueProto = new.target.prototype;
|
12567
|
-
super(message);
|
12568
|
-
this.errorType = 'FailedToNegotiateWithServerError';
|
12569
|
-
// Workaround issue in Typescript compiler
|
12570
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12571
|
-
this.__proto__ = trueProto;
|
12572
|
-
}
|
12573
|
-
}
|
12574
|
-
/** Error thrown when multiple errors have occured. */
|
12575
|
-
/** @private */
|
12576
|
-
class AggregateErrors extends Error {
|
12577
|
-
/** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
|
12578
|
-
*
|
12579
|
-
* @param {string} message A descriptive error message.
|
12580
|
-
* @param {Error[]} innerErrors The collection of errors this error is aggregating.
|
12581
|
-
*/
|
12582
|
-
constructor(message, innerErrors) {
|
12583
|
-
const trueProto = new.target.prototype;
|
12584
|
-
super(message);
|
12585
|
-
this.innerErrors = innerErrors;
|
12586
|
-
// Workaround issue in Typescript compiler
|
12587
|
-
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
12588
|
-
this.__proto__ = trueProto;
|
12589
|
-
}
|
12590
|
-
}
|
12591
|
-
|
12592
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12593
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
12594
|
-
/** Represents an HTTP response. */
|
12595
|
-
class HttpResponse {
|
12596
|
-
constructor(statusCode, statusText, content) {
|
12597
|
-
this.statusCode = statusCode;
|
12598
|
-
this.statusText = statusText;
|
12599
|
-
this.content = content;
|
12600
|
-
}
|
12601
|
-
}
|
12602
|
-
/** Abstraction over an HTTP client.
|
12603
|
-
*
|
12604
|
-
* This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
|
12605
|
-
*/
|
12606
|
-
class HttpClient {
|
12607
|
-
get(url, options) {
|
12608
|
-
return this.send({
|
12609
|
-
...options,
|
12610
|
-
method: "GET",
|
12611
|
-
url,
|
12612
|
-
});
|
12613
|
-
}
|
12614
|
-
post(url, options) {
|
12615
|
-
return this.send({
|
12616
|
-
...options,
|
12617
|
-
method: "POST",
|
12618
|
-
url,
|
12619
|
-
});
|
12620
|
-
}
|
12621
|
-
delete(url, options) {
|
12622
|
-
return this.send({
|
12623
|
-
...options,
|
12624
|
-
method: "DELETE",
|
12625
|
-
url,
|
12626
|
-
});
|
12627
|
-
}
|
12628
|
-
/** Gets all cookies that apply to the specified URL.
|
12629
|
-
*
|
12630
|
-
* @param url The URL that the cookies are valid for.
|
12631
|
-
* @returns {string} A string containing all the key-value cookie pairs for the specified URL.
|
12632
|
-
*/
|
12633
|
-
// @ts-ignore
|
12634
|
-
getCookieString(url) {
|
12635
|
-
return "";
|
12636
|
-
}
|
12637
|
-
}
|
12638
|
-
|
12639
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12640
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
12641
|
-
// These values are designed to match the ASP.NET Log Levels since that's the pattern we're emulating here.
|
12642
|
-
/** Indicates the severity of a log message.
|
12643
|
-
*
|
12644
|
-
* Log Levels are ordered in increasing severity. So `Debug` is more severe than `Trace`, etc.
|
12645
|
-
*/
|
12646
|
-
var LogLevel;
|
12647
|
-
(function (LogLevel) {
|
12648
|
-
/** Log level for very low severity diagnostic messages. */
|
12649
|
-
LogLevel[LogLevel["Trace"] = 0] = "Trace";
|
12650
|
-
/** Log level for low severity diagnostic messages. */
|
12651
|
-
LogLevel[LogLevel["Debug"] = 1] = "Debug";
|
12652
|
-
/** Log level for informational diagnostic messages. */
|
12653
|
-
LogLevel[LogLevel["Information"] = 2] = "Information";
|
12654
|
-
/** Log level for diagnostic messages that indicate a non-fatal problem. */
|
12655
|
-
LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
12656
|
-
/** Log level for diagnostic messages that indicate a failure in the current operation. */
|
12657
|
-
LogLevel[LogLevel["Error"] = 4] = "Error";
|
12658
|
-
/** Log level for diagnostic messages that indicate a failure that will terminate the entire application. */
|
12659
|
-
LogLevel[LogLevel["Critical"] = 5] = "Critical";
|
12660
|
-
/** The highest possible log level. Used when configuring logging to indicate that no log messages should be emitted. */
|
12661
|
-
LogLevel[LogLevel["None"] = 6] = "None";
|
12662
|
-
})(LogLevel || (LogLevel = {}));
|
12663
|
-
|
12664
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12665
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
12666
|
-
/** A logger that does nothing when log messages are sent to it. */
|
12667
|
-
class NullLogger {
|
12668
|
-
constructor() { }
|
12669
|
-
/** @inheritDoc */
|
12670
|
-
// eslint-disable-next-line
|
12671
|
-
log(_logLevel, _message) {
|
12672
|
-
}
|
12673
|
-
}
|
12674
|
-
/** The singleton instance of the {@link @microsoft/signalr.NullLogger}. */
|
12675
|
-
NullLogger.instance = new NullLogger();
|
12676
|
-
|
12677
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12678
|
-
// Version token that will be replaced by the prepack command
|
12679
|
-
/** The version of the SignalR client. */
|
12680
|
-
const VERSION = "6.0.3";
|
12681
|
-
/** @private */
|
12682
|
-
class Arg {
|
12683
|
-
static isRequired(val, name) {
|
12684
|
-
if (val === null || val === undefined) {
|
12685
|
-
throw new Error(`The '${name}' argument is required.`);
|
12686
|
-
}
|
12687
|
-
}
|
12688
|
-
static isNotEmpty(val, name) {
|
12689
|
-
if (!val || val.match(/^\s*$/)) {
|
12690
|
-
throw new Error(`The '${name}' argument should not be empty.`);
|
12691
|
-
}
|
12692
|
-
}
|
12693
|
-
static isIn(val, values, name) {
|
12694
|
-
// TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.
|
12695
|
-
if (!(val in values)) {
|
12696
|
-
throw new Error(`Unknown ${name} value: ${val}.`);
|
12697
|
-
}
|
12698
|
-
}
|
12699
|
-
}
|
12700
|
-
/** @private */
|
12701
|
-
class Platform {
|
12702
|
-
// react-native has a window but no document so we should check both
|
12703
|
-
static get isBrowser() {
|
12704
|
-
return typeof window === "object" && typeof window.document === "object";
|
12705
|
-
}
|
12706
|
-
// WebWorkers don't have a window object so the isBrowser check would fail
|
12707
|
-
static get isWebWorker() {
|
12708
|
-
return typeof self === "object" && "importScripts" in self;
|
12709
|
-
}
|
12710
|
-
// react-native has a window but no document
|
12711
|
-
static get isReactNative() {
|
12712
|
-
return typeof window === "object" && typeof window.document === "undefined";
|
12713
|
-
}
|
12714
|
-
// Node apps shouldn't have a window object, but WebWorkers don't either
|
12715
|
-
// so we need to check for both WebWorker and window
|
12716
|
-
static get isNode() {
|
12717
|
-
return !this.isBrowser && !this.isWebWorker && !this.isReactNative;
|
12718
|
-
}
|
12719
|
-
}
|
12720
|
-
/** @private */
|
12721
|
-
function getDataDetail(data, includeContent) {
|
12722
|
-
let detail = "";
|
12723
|
-
if (isArrayBuffer(data)) {
|
12724
|
-
detail = `Binary data of length ${data.byteLength}`;
|
12725
|
-
if (includeContent) {
|
12726
|
-
detail += `. Content: '${formatArrayBuffer(data)}'`;
|
12727
|
-
}
|
12728
|
-
}
|
12729
|
-
else if (typeof data === "string") {
|
12730
|
-
detail = `String data of length ${data.length}`;
|
12731
|
-
if (includeContent) {
|
12732
|
-
detail += `. Content: '${data}'`;
|
12733
|
-
}
|
12734
|
-
}
|
12735
|
-
return detail;
|
12736
|
-
}
|
12737
|
-
/** @private */
|
12738
|
-
function formatArrayBuffer(data) {
|
12739
|
-
const view = new Uint8Array(data);
|
12740
|
-
// Uint8Array.map only supports returning another Uint8Array?
|
12741
|
-
let str = "";
|
12742
|
-
view.forEach((num) => {
|
12743
|
-
const pad = num < 16 ? "0" : "";
|
12744
|
-
str += `0x${pad}${num.toString(16)} `;
|
12745
|
-
});
|
12746
|
-
// Trim of trailing space.
|
12747
|
-
return str.substr(0, str.length - 1);
|
12748
|
-
}
|
12749
|
-
// Also in signalr-protocol-msgpack/Utils.ts
|
12750
|
-
/** @private */
|
12751
|
-
function isArrayBuffer(val) {
|
12752
|
-
return val && typeof ArrayBuffer !== "undefined" &&
|
12753
|
-
(val instanceof ArrayBuffer ||
|
12754
|
-
// Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
|
12755
|
-
(val.constructor && val.constructor.name === "ArrayBuffer"));
|
12756
|
-
}
|
12757
|
-
/** @private */
|
12758
|
-
async function sendMessage(logger, transportName, httpClient, url, accessTokenFactory, content, options) {
|
12759
|
-
let headers = {};
|
12760
|
-
if (accessTokenFactory) {
|
12761
|
-
const token = await accessTokenFactory();
|
12762
|
-
if (token) {
|
12763
|
-
headers = {
|
12764
|
-
["Authorization"]: `Bearer ${token}`,
|
12765
|
-
};
|
12766
|
-
}
|
12767
|
-
}
|
12768
|
-
const [name, value] = getUserAgentHeader();
|
12769
|
-
headers[name] = value;
|
12770
|
-
logger.log(LogLevel.Trace, `(${transportName} transport) sending data. ${getDataDetail(content, options.logMessageContent)}.`);
|
12771
|
-
const responseType = isArrayBuffer(content) ? "arraybuffer" : "text";
|
12772
|
-
const response = await httpClient.post(url, {
|
12773
|
-
content,
|
12774
|
-
headers: { ...headers, ...options.headers },
|
12775
|
-
responseType,
|
12776
|
-
timeout: options.timeout,
|
12777
|
-
withCredentials: options.withCredentials,
|
12778
|
-
});
|
12779
|
-
logger.log(LogLevel.Trace, `(${transportName} transport) request complete. Response status: ${response.statusCode}.`);
|
12780
|
-
}
|
12781
|
-
/** @private */
|
12782
|
-
function createLogger(logger) {
|
12783
|
-
if (logger === undefined) {
|
12784
|
-
return new ConsoleLogger(LogLevel.Information);
|
12785
|
-
}
|
12786
|
-
if (logger === null) {
|
12787
|
-
return NullLogger.instance;
|
12788
|
-
}
|
12789
|
-
if (logger.log !== undefined) {
|
12790
|
-
return logger;
|
12791
|
-
}
|
12792
|
-
return new ConsoleLogger(logger);
|
12793
|
-
}
|
12794
|
-
/** @private */
|
12795
|
-
class SubjectSubscription {
|
12796
|
-
constructor(subject, observer) {
|
12797
|
-
this._subject = subject;
|
12798
|
-
this._observer = observer;
|
12799
|
-
}
|
12800
|
-
dispose() {
|
12801
|
-
const index = this._subject.observers.indexOf(this._observer);
|
12802
|
-
if (index > -1) {
|
12803
|
-
this._subject.observers.splice(index, 1);
|
12804
|
-
}
|
12805
|
-
if (this._subject.observers.length === 0 && this._subject.cancelCallback) {
|
12806
|
-
this._subject.cancelCallback().catch((_) => { });
|
12807
|
-
}
|
12808
|
-
}
|
12809
|
-
}
|
12810
|
-
/** @private */
|
12811
|
-
class ConsoleLogger {
|
12812
|
-
constructor(minimumLogLevel) {
|
12813
|
-
this._minLevel = minimumLogLevel;
|
12814
|
-
this.out = console;
|
12815
|
-
}
|
12816
|
-
log(logLevel, message) {
|
12817
|
-
if (logLevel >= this._minLevel) {
|
12818
|
-
const msg = `[${new Date().toISOString()}] ${LogLevel[logLevel]}: ${message}`;
|
12819
|
-
switch (logLevel) {
|
12820
|
-
case LogLevel.Critical:
|
12821
|
-
case LogLevel.Error:
|
12822
|
-
this.out.error(msg);
|
12823
|
-
break;
|
12824
|
-
case LogLevel.Warning:
|
12825
|
-
this.out.warn(msg);
|
12826
|
-
break;
|
12827
|
-
case LogLevel.Information:
|
12828
|
-
this.out.info(msg);
|
12829
|
-
break;
|
12830
|
-
default:
|
12831
|
-
// console.debug only goes to attached debuggers in Node, so we use console.log for Trace and Debug
|
12832
|
-
this.out.log(msg);
|
12833
|
-
break;
|
12834
|
-
}
|
12835
|
-
}
|
12836
|
-
}
|
12837
|
-
}
|
12838
|
-
/** @private */
|
12839
|
-
function getUserAgentHeader() {
|
12840
|
-
let userAgentHeaderName = "X-SignalR-User-Agent";
|
12841
|
-
if (Platform.isNode) {
|
12842
|
-
userAgentHeaderName = "User-Agent";
|
12843
|
-
}
|
12844
|
-
return [userAgentHeaderName, constructUserAgent(VERSION, getOsName(), getRuntime(), getRuntimeVersion())];
|
12845
|
-
}
|
12846
|
-
/** @private */
|
12847
|
-
function constructUserAgent(version, os, runtime, runtimeVersion) {
|
12848
|
-
// Microsoft SignalR/[Version] ([Detailed Version]; [Operating System]; [Runtime]; [Runtime Version])
|
12849
|
-
let userAgent = "Microsoft SignalR/";
|
12850
|
-
const majorAndMinor = version.split(".");
|
12851
|
-
userAgent += `${majorAndMinor[0]}.${majorAndMinor[1]}`;
|
12852
|
-
userAgent += ` (${version}; `;
|
12853
|
-
if (os && os !== "") {
|
12854
|
-
userAgent += `${os}; `;
|
12855
|
-
}
|
12856
|
-
else {
|
12857
|
-
userAgent += "Unknown OS; ";
|
12858
|
-
}
|
12859
|
-
userAgent += `${runtime}`;
|
12860
|
-
if (runtimeVersion) {
|
12861
|
-
userAgent += `; ${runtimeVersion}`;
|
12862
|
-
}
|
12863
|
-
else {
|
12864
|
-
userAgent += "; Unknown Runtime Version";
|
12865
|
-
}
|
12866
|
-
userAgent += ")";
|
12867
|
-
return userAgent;
|
12868
|
-
}
|
12869
|
-
// eslint-disable-next-line spaced-comment
|
12870
|
-
/*#__PURE__*/ function getOsName() {
|
12871
|
-
if (Platform.isNode) {
|
12872
|
-
switch (process.platform) {
|
12873
|
-
case "win32":
|
12874
|
-
return "Windows NT";
|
12875
|
-
case "darwin":
|
12876
|
-
return "macOS";
|
12877
|
-
case "linux":
|
12878
|
-
return "Linux";
|
12879
|
-
default:
|
12880
|
-
return process.platform;
|
12881
|
-
}
|
12882
|
-
}
|
12883
|
-
else {
|
12884
|
-
return "";
|
12885
|
-
}
|
12886
|
-
}
|
12887
|
-
// eslint-disable-next-line spaced-comment
|
12888
|
-
/*#__PURE__*/ function getRuntimeVersion() {
|
12889
|
-
if (Platform.isNode) {
|
12890
|
-
return process.versions.node;
|
12891
|
-
}
|
12892
|
-
return undefined;
|
12893
|
-
}
|
12894
|
-
function getRuntime() {
|
12895
|
-
if (Platform.isNode) {
|
12896
|
-
return "NodeJS";
|
12897
|
-
}
|
12898
|
-
else {
|
12899
|
-
return "Browser";
|
12900
|
-
}
|
12901
|
-
}
|
12902
|
-
/** @private */
|
12903
|
-
function getErrorString(e) {
|
12904
|
-
if (e.stack) {
|
12905
|
-
return e.stack;
|
12906
|
-
}
|
12907
|
-
else if (e.message) {
|
12908
|
-
return e.message;
|
12909
|
-
}
|
12910
|
-
return `${e}`;
|
12911
|
-
}
|
12912
|
-
/** @private */
|
12913
|
-
function getGlobalThis() {
|
12914
|
-
// globalThis is semi-new and not available in Node until v12
|
12915
|
-
if (typeof globalThis !== "undefined") {
|
12916
|
-
return globalThis;
|
12917
|
-
}
|
12918
|
-
if (typeof self !== "undefined") {
|
12919
|
-
return self;
|
12920
|
-
}
|
12921
|
-
if (typeof window !== "undefined") {
|
12922
|
-
return window;
|
12923
|
-
}
|
12924
|
-
if (typeof global !== "undefined") {
|
12925
|
-
return global;
|
12926
|
-
}
|
12927
|
-
throw new Error("could not find global");
|
12928
|
-
}
|
12929
|
-
|
12930
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
12931
|
-
class FetchHttpClient extends HttpClient {
|
12932
|
-
constructor(logger) {
|
12933
|
-
super();
|
12934
|
-
this._logger = logger;
|
12935
|
-
if (typeof fetch === "undefined") {
|
12936
|
-
// In order to ignore the dynamic require in webpack builds we need to do this magic
|
12937
|
-
// @ts-ignore: TS doesn't know about these names
|
12938
|
-
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
12939
|
-
// Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
|
12940
|
-
this._jar = new (requireFunc("tough-cookie")).CookieJar();
|
12941
|
-
this._fetchType = requireFunc("node-fetch");
|
12942
|
-
// node-fetch doesn't have a nice API for getting and setting cookies
|
12943
|
-
// fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
|
12944
|
-
this._fetchType = requireFunc("fetch-cookie")(this._fetchType, this._jar);
|
12945
|
-
}
|
12946
|
-
else {
|
12947
|
-
this._fetchType = fetch.bind(getGlobalThis());
|
12948
|
-
}
|
12949
|
-
if (typeof AbortController === "undefined") {
|
12950
|
-
// In order to ignore the dynamic require in webpack builds we need to do this magic
|
12951
|
-
// @ts-ignore: TS doesn't know about these names
|
12952
|
-
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
12953
|
-
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
|
12954
|
-
this._abortControllerType = requireFunc("abort-controller");
|
12955
|
-
}
|
12956
|
-
else {
|
12957
|
-
this._abortControllerType = AbortController;
|
12958
|
-
}
|
12959
|
-
}
|
12960
|
-
/** @inheritDoc */
|
12961
|
-
async send(request) {
|
12962
|
-
// Check that abort was not signaled before calling send
|
12963
|
-
if (request.abortSignal && request.abortSignal.aborted) {
|
12964
|
-
throw new AbortError();
|
12965
|
-
}
|
12966
|
-
if (!request.method) {
|
12967
|
-
throw new Error("No method defined.");
|
12968
|
-
}
|
12969
|
-
if (!request.url) {
|
12970
|
-
throw new Error("No url defined.");
|
12971
|
-
}
|
12972
|
-
const abortController = new this._abortControllerType();
|
12973
|
-
let error;
|
12974
|
-
// Hook our abortSignal into the abort controller
|
12975
|
-
if (request.abortSignal) {
|
12976
|
-
request.abortSignal.onabort = () => {
|
12977
|
-
abortController.abort();
|
12978
|
-
error = new AbortError();
|
12979
|
-
};
|
12980
|
-
}
|
12981
|
-
// If a timeout has been passed in, setup a timeout to call abort
|
12982
|
-
// Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
|
12983
|
-
let timeoutId = null;
|
12984
|
-
if (request.timeout) {
|
12985
|
-
const msTimeout = request.timeout;
|
12986
|
-
timeoutId = setTimeout(() => {
|
12987
|
-
abortController.abort();
|
12988
|
-
this._logger.log(LogLevel.Warning, `Timeout from HTTP request.`);
|
12989
|
-
error = new TimeoutError();
|
12990
|
-
}, msTimeout);
|
12991
|
-
}
|
12992
|
-
let response;
|
12993
|
-
try {
|
12994
|
-
response = await this._fetchType(request.url, {
|
12995
|
-
body: request.content,
|
12996
|
-
cache: "no-cache",
|
12997
|
-
credentials: request.withCredentials === true ? "include" : "same-origin",
|
12998
|
-
headers: {
|
12999
|
-
"Content-Type": "text/plain;charset=UTF-8",
|
13000
|
-
"X-Requested-With": "XMLHttpRequest",
|
13001
|
-
...request.headers,
|
13002
|
-
},
|
13003
|
-
method: request.method,
|
13004
|
-
mode: "cors",
|
13005
|
-
redirect: "follow",
|
13006
|
-
signal: abortController.signal,
|
13007
|
-
});
|
13008
|
-
}
|
13009
|
-
catch (e) {
|
13010
|
-
if (error) {
|
13011
|
-
throw error;
|
13012
|
-
}
|
13013
|
-
this._logger.log(LogLevel.Warning, `Error from HTTP request. ${e}.`);
|
13014
|
-
throw e;
|
13015
|
-
}
|
13016
|
-
finally {
|
13017
|
-
if (timeoutId) {
|
13018
|
-
clearTimeout(timeoutId);
|
13019
|
-
}
|
13020
|
-
if (request.abortSignal) {
|
13021
|
-
request.abortSignal.onabort = null;
|
13022
|
-
}
|
13023
|
-
}
|
13024
|
-
if (!response.ok) {
|
13025
|
-
const errorMessage = await deserializeContent(response, "text");
|
13026
|
-
throw new HttpError(errorMessage || response.statusText, response.status);
|
13027
|
-
}
|
13028
|
-
const content = deserializeContent(response, request.responseType);
|
13029
|
-
const payload = await content;
|
13030
|
-
return new HttpResponse(response.status, response.statusText, payload);
|
13031
|
-
}
|
13032
|
-
getCookieString(url) {
|
13033
|
-
let cookies = "";
|
13034
|
-
if (Platform.isNode && this._jar) {
|
13035
|
-
// @ts-ignore: unused variable
|
13036
|
-
this._jar.getCookies(url, (e, c) => cookies = c.join("; "));
|
13037
|
-
}
|
13038
|
-
return cookies;
|
13039
|
-
}
|
13040
|
-
}
|
13041
|
-
function deserializeContent(response, responseType) {
|
13042
|
-
let content;
|
13043
|
-
switch (responseType) {
|
13044
|
-
case "arraybuffer":
|
13045
|
-
content = response.arrayBuffer();
|
13046
|
-
break;
|
13047
|
-
case "text":
|
13048
|
-
content = response.text();
|
13049
|
-
break;
|
13050
|
-
case "blob":
|
13051
|
-
case "document":
|
13052
|
-
case "json":
|
13053
|
-
throw new Error(`${responseType} is not supported.`);
|
13054
|
-
default:
|
13055
|
-
content = response.text();
|
13056
|
-
break;
|
13057
|
-
}
|
13058
|
-
return content;
|
13059
|
-
}
|
13060
|
-
|
13061
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13062
|
-
class XhrHttpClient extends HttpClient {
|
13063
|
-
constructor(logger) {
|
13064
|
-
super();
|
13065
|
-
this._logger = logger;
|
13066
|
-
}
|
13067
|
-
/** @inheritDoc */
|
13068
|
-
send(request) {
|
13069
|
-
// Check that abort was not signaled before calling send
|
13070
|
-
if (request.abortSignal && request.abortSignal.aborted) {
|
13071
|
-
return Promise.reject(new AbortError());
|
13072
|
-
}
|
13073
|
-
if (!request.method) {
|
13074
|
-
return Promise.reject(new Error("No method defined."));
|
13075
|
-
}
|
13076
|
-
if (!request.url) {
|
13077
|
-
return Promise.reject(new Error("No url defined."));
|
13078
|
-
}
|
13079
|
-
return new Promise((resolve, reject) => {
|
13080
|
-
const xhr = new XMLHttpRequest();
|
13081
|
-
xhr.open(request.method, request.url, true);
|
13082
|
-
xhr.withCredentials = request.withCredentials === undefined ? true : request.withCredentials;
|
13083
|
-
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
13084
|
-
// Explicitly setting the Content-Type header for React Native on Android platform.
|
13085
|
-
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
|
13086
|
-
const headers = request.headers;
|
13087
|
-
if (headers) {
|
13088
|
-
Object.keys(headers)
|
13089
|
-
.forEach((header) => {
|
13090
|
-
xhr.setRequestHeader(header, headers[header]);
|
13091
|
-
});
|
13092
|
-
}
|
13093
|
-
if (request.responseType) {
|
13094
|
-
xhr.responseType = request.responseType;
|
13095
|
-
}
|
13096
|
-
if (request.abortSignal) {
|
13097
|
-
request.abortSignal.onabort = () => {
|
13098
|
-
xhr.abort();
|
13099
|
-
reject(new AbortError());
|
13100
|
-
};
|
13101
|
-
}
|
13102
|
-
if (request.timeout) {
|
13103
|
-
xhr.timeout = request.timeout;
|
13104
|
-
}
|
13105
|
-
xhr.onload = () => {
|
13106
|
-
if (request.abortSignal) {
|
13107
|
-
request.abortSignal.onabort = null;
|
13108
|
-
}
|
13109
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
13110
|
-
resolve(new HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
13111
|
-
}
|
13112
|
-
else {
|
13113
|
-
reject(new HttpError(xhr.response || xhr.responseText || xhr.statusText, xhr.status));
|
13114
|
-
}
|
13115
|
-
};
|
13116
|
-
xhr.onerror = () => {
|
13117
|
-
this._logger.log(LogLevel.Warning, `Error from HTTP request. ${xhr.status}: ${xhr.statusText}.`);
|
13118
|
-
reject(new HttpError(xhr.statusText, xhr.status));
|
13119
|
-
};
|
13120
|
-
xhr.ontimeout = () => {
|
13121
|
-
this._logger.log(LogLevel.Warning, `Timeout from HTTP request.`);
|
13122
|
-
reject(new TimeoutError());
|
13123
|
-
};
|
13124
|
-
xhr.send(request.content || "");
|
13125
|
-
});
|
13126
|
-
}
|
13127
|
-
}
|
13128
|
-
|
13129
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13130
|
-
/** Default implementation of {@link @microsoft/signalr.HttpClient}. */
|
13131
|
-
class DefaultHttpClient extends HttpClient {
|
13132
|
-
/** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
|
13133
|
-
constructor(logger) {
|
13134
|
-
super();
|
13135
|
-
if (typeof fetch !== "undefined" || Platform.isNode) {
|
13136
|
-
this._httpClient = new FetchHttpClient(logger);
|
13137
|
-
}
|
13138
|
-
else if (typeof XMLHttpRequest !== "undefined") {
|
13139
|
-
this._httpClient = new XhrHttpClient(logger);
|
13140
|
-
}
|
13141
|
-
else {
|
13142
|
-
throw new Error("No usable HttpClient found.");
|
13143
|
-
}
|
13144
|
-
}
|
13145
|
-
/** @inheritDoc */
|
13146
|
-
send(request) {
|
13147
|
-
// Check that abort was not signaled before calling send
|
13148
|
-
if (request.abortSignal && request.abortSignal.aborted) {
|
13149
|
-
return Promise.reject(new AbortError());
|
13150
|
-
}
|
13151
|
-
if (!request.method) {
|
13152
|
-
return Promise.reject(new Error("No method defined."));
|
13153
|
-
}
|
13154
|
-
if (!request.url) {
|
13155
|
-
return Promise.reject(new Error("No url defined."));
|
13156
|
-
}
|
13157
|
-
return this._httpClient.send(request);
|
13158
|
-
}
|
13159
|
-
getCookieString(url) {
|
13160
|
-
return this._httpClient.getCookieString(url);
|
13161
|
-
}
|
13162
|
-
}
|
13163
|
-
|
13164
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13165
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
13166
|
-
// Not exported from index
|
13167
|
-
/** @private */
|
13168
|
-
class TextMessageFormat {
|
13169
|
-
static write(output) {
|
13170
|
-
return `${output}${TextMessageFormat.RecordSeparator}`;
|
13171
|
-
}
|
13172
|
-
static parse(input) {
|
13173
|
-
if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
|
13174
|
-
throw new Error("Message is incomplete.");
|
13175
|
-
}
|
13176
|
-
const messages = input.split(TextMessageFormat.RecordSeparator);
|
13177
|
-
messages.pop();
|
13178
|
-
return messages;
|
13179
|
-
}
|
13180
|
-
}
|
13181
|
-
TextMessageFormat.RecordSeparatorCode = 0x1e;
|
13182
|
-
TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
|
13183
|
-
|
13184
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13185
|
-
/** @private */
|
13186
|
-
class HandshakeProtocol {
|
13187
|
-
// Handshake request is always JSON
|
13188
|
-
writeHandshakeRequest(handshakeRequest) {
|
13189
|
-
return TextMessageFormat.write(JSON.stringify(handshakeRequest));
|
13190
|
-
}
|
13191
|
-
parseHandshakeResponse(data) {
|
13192
|
-
let messageData;
|
13193
|
-
let remainingData;
|
13194
|
-
if (isArrayBuffer(data)) {
|
13195
|
-
// Format is binary but still need to read JSON text from handshake response
|
13196
|
-
const binaryData = new Uint8Array(data);
|
13197
|
-
const separatorIndex = binaryData.indexOf(TextMessageFormat.RecordSeparatorCode);
|
13198
|
-
if (separatorIndex === -1) {
|
13199
|
-
throw new Error("Message is incomplete.");
|
13200
|
-
}
|
13201
|
-
// content before separator is handshake response
|
13202
|
-
// optional content after is additional messages
|
13203
|
-
const responseLength = separatorIndex + 1;
|
13204
|
-
messageData = String.fromCharCode.apply(null, Array.prototype.slice.call(binaryData.slice(0, responseLength)));
|
13205
|
-
remainingData = (binaryData.byteLength > responseLength) ? binaryData.slice(responseLength).buffer : null;
|
13206
|
-
}
|
13207
|
-
else {
|
13208
|
-
const textData = data;
|
13209
|
-
const separatorIndex = textData.indexOf(TextMessageFormat.RecordSeparator);
|
13210
|
-
if (separatorIndex === -1) {
|
13211
|
-
throw new Error("Message is incomplete.");
|
13212
|
-
}
|
13213
|
-
// content before separator is handshake response
|
13214
|
-
// optional content after is additional messages
|
13215
|
-
const responseLength = separatorIndex + 1;
|
13216
|
-
messageData = textData.substring(0, responseLength);
|
13217
|
-
remainingData = (textData.length > responseLength) ? textData.substring(responseLength) : null;
|
13218
|
-
}
|
13219
|
-
// At this point we should have just the single handshake message
|
13220
|
-
const messages = TextMessageFormat.parse(messageData);
|
13221
|
-
const response = JSON.parse(messages[0]);
|
13222
|
-
if (response.type) {
|
13223
|
-
throw new Error("Expected a handshake response from the server.");
|
13224
|
-
}
|
13225
|
-
const responseMessage = response;
|
13226
|
-
// multiple messages could have arrived with handshake
|
13227
|
-
// return additional data to be parsed as usual, or null if all parsed
|
13228
|
-
return [remainingData, responseMessage];
|
13229
|
-
}
|
13230
|
-
}
|
13231
|
-
|
13232
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13233
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
13234
|
-
/** Defines the type of a Hub Message. */
|
13235
|
-
var MessageType;
|
13236
|
-
(function (MessageType) {
|
13237
|
-
/** Indicates the message is an Invocation message and implements the {@link @microsoft/signalr.InvocationMessage} interface. */
|
13238
|
-
MessageType[MessageType["Invocation"] = 1] = "Invocation";
|
13239
|
-
/** Indicates the message is a StreamItem message and implements the {@link @microsoft/signalr.StreamItemMessage} interface. */
|
13240
|
-
MessageType[MessageType["StreamItem"] = 2] = "StreamItem";
|
13241
|
-
/** Indicates the message is a Completion message and implements the {@link @microsoft/signalr.CompletionMessage} interface. */
|
13242
|
-
MessageType[MessageType["Completion"] = 3] = "Completion";
|
13243
|
-
/** Indicates the message is a Stream Invocation message and implements the {@link @microsoft/signalr.StreamInvocationMessage} interface. */
|
13244
|
-
MessageType[MessageType["StreamInvocation"] = 4] = "StreamInvocation";
|
13245
|
-
/** Indicates the message is a Cancel Invocation message and implements the {@link @microsoft/signalr.CancelInvocationMessage} interface. */
|
13246
|
-
MessageType[MessageType["CancelInvocation"] = 5] = "CancelInvocation";
|
13247
|
-
/** Indicates the message is a Ping message and implements the {@link @microsoft/signalr.PingMessage} interface. */
|
13248
|
-
MessageType[MessageType["Ping"] = 6] = "Ping";
|
13249
|
-
/** Indicates the message is a Close message and implements the {@link @microsoft/signalr.CloseMessage} interface. */
|
13250
|
-
MessageType[MessageType["Close"] = 7] = "Close";
|
13251
|
-
})(MessageType || (MessageType = {}));
|
13252
|
-
|
13253
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13254
|
-
/** Stream implementation to stream items to the server. */
|
13255
|
-
class Subject {
|
13256
|
-
constructor() {
|
13257
|
-
this.observers = [];
|
13258
|
-
}
|
13259
|
-
next(item) {
|
13260
|
-
for (const observer of this.observers) {
|
13261
|
-
observer.next(item);
|
13262
|
-
}
|
13263
|
-
}
|
13264
|
-
error(err) {
|
13265
|
-
for (const observer of this.observers) {
|
13266
|
-
if (observer.error) {
|
13267
|
-
observer.error(err);
|
13268
|
-
}
|
13269
|
-
}
|
13270
|
-
}
|
13271
|
-
complete() {
|
13272
|
-
for (const observer of this.observers) {
|
13273
|
-
if (observer.complete) {
|
13274
|
-
observer.complete();
|
13275
|
-
}
|
13276
|
-
}
|
13277
|
-
}
|
13278
|
-
subscribe(observer) {
|
13279
|
-
this.observers.push(observer);
|
13280
|
-
return new SubjectSubscription(this, observer);
|
13281
|
-
}
|
13282
|
-
}
|
13283
|
-
|
13284
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
13285
|
-
const DEFAULT_TIMEOUT_IN_MS = 30 * 1000;
|
13286
|
-
const DEFAULT_PING_INTERVAL_IN_MS = 15 * 1000;
|
13287
|
-
/** Describes the current state of the {@link HubConnection} to the server. */
|
13288
|
-
var HubConnectionState;
|
13289
|
-
(function (HubConnectionState) {
|
13290
|
-
/** The hub connection is disconnected. */
|
13291
|
-
HubConnectionState["Disconnected"] = "Disconnected";
|
13292
|
-
/** The hub connection is connecting. */
|
13293
|
-
HubConnectionState["Connecting"] = "Connecting";
|
13294
|
-
/** The hub connection is connected. */
|
13295
|
-
HubConnectionState["Connected"] = "Connected";
|
13296
|
-
/** The hub connection is disconnecting. */
|
13297
|
-
HubConnectionState["Disconnecting"] = "Disconnecting";
|
13298
|
-
/** The hub connection is reconnecting. */
|
13299
|
-
HubConnectionState["Reconnecting"] = "Reconnecting";
|
13300
|
-
})(HubConnectionState || (HubConnectionState = {}));
|
13301
|
-
/** Represents a connection to a SignalR Hub. */
|
13302
|
-
class HubConnection {
|
13303
|
-
constructor(connection, logger, protocol, reconnectPolicy) {
|
13304
|
-
this._nextKeepAlive = 0;
|
13305
|
-
this._freezeEventListener = () => {
|
13306
|
-
this._logger.log(LogLevel.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://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep");
|
13307
|
-
};
|
13308
|
-
Arg.isRequired(connection, "connection");
|
13309
|
-
Arg.isRequired(logger, "logger");
|
13310
|
-
Arg.isRequired(protocol, "protocol");
|
13311
|
-
this.serverTimeoutInMilliseconds = DEFAULT_TIMEOUT_IN_MS;
|
13312
|
-
this.keepAliveIntervalInMilliseconds = DEFAULT_PING_INTERVAL_IN_MS;
|
13313
|
-
this._logger = logger;
|
13314
|
-
this._protocol = protocol;
|
13315
|
-
this.connection = connection;
|
13316
|
-
this._reconnectPolicy = reconnectPolicy;
|
13317
|
-
this._handshakeProtocol = new HandshakeProtocol();
|
13318
|
-
this.connection.onreceive = (data) => this._processIncomingData(data);
|
13319
|
-
this.connection.onclose = (error) => this._connectionClosed(error);
|
13320
|
-
this._callbacks = {};
|
13321
|
-
this._methods = {};
|
13322
|
-
this._closedCallbacks = [];
|
13323
|
-
this._reconnectingCallbacks = [];
|
13324
|
-
this._reconnectedCallbacks = [];
|
13325
|
-
this._invocationId = 0;
|
13326
|
-
this._receivedHandshakeResponse = false;
|
13327
|
-
this._connectionState = HubConnectionState.Disconnected;
|
13328
|
-
this._connectionStarted = false;
|
13329
|
-
this._cachedPingMessage = this._protocol.writeMessage({ type: MessageType.Ping });
|
13330
|
-
}
|
13331
|
-
/** @internal */
|
13332
|
-
// Using a public static factory method means we can have a private constructor and an _internal_
|
13333
|
-
// create method that can be used by HubConnectionBuilder. An "internal" constructor would just
|
13334
|
-
// be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
|
13335
|
-
// public parameter-less constructor.
|
13336
|
-
static create(connection, logger, protocol, reconnectPolicy) {
|
13337
|
-
return new HubConnection(connection, logger, protocol, reconnectPolicy);
|
13338
|
-
}
|
13339
|
-
/** Indicates the state of the {@link HubConnection} to the server. */
|
13340
|
-
get state() {
|
13341
|
-
return this._connectionState;
|
13342
|
-
}
|
13343
|
-
/** Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either
|
13344
|
-
* in the disconnected state or if the negotiation step was skipped.
|
13345
|
-
*/
|
13346
|
-
get connectionId() {
|
13347
|
-
return this.connection ? (this.connection.connectionId || null) : null;
|
13348
|
-
}
|
13349
|
-
/** Indicates the url of the {@link HubConnection} to the server. */
|
13350
|
-
get baseUrl() {
|
13351
|
-
return this.connection.baseUrl || "";
|
13352
|
-
}
|
13353
|
-
/**
|
13354
|
-
* Sets a new url for the HubConnection. Note that the url can only be changed when the connection is in either the Disconnected or
|
13355
|
-
* Reconnecting states.
|
13356
|
-
* @param {string} url The url to connect to.
|
13357
|
-
*/
|
13358
|
-
set baseUrl(url) {
|
13359
|
-
if (this._connectionState !== HubConnectionState.Disconnected && this._connectionState !== HubConnectionState.Reconnecting) {
|
13360
|
-
throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");
|
13361
|
-
}
|
13362
|
-
if (!url) {
|
13363
|
-
throw new Error("The HubConnection url must be a valid url.");
|
13364
|
-
}
|
13365
|
-
this.connection.baseUrl = url;
|
13366
|
-
}
|
13367
|
-
/** Starts the connection.
|
13368
|
-
*
|
13369
|
-
* @returns {Promise<void>} A Promise that resolves when the connection has been successfully established, or rejects with an error.
|
13370
|
-
*/
|
13371
|
-
start() {
|
13372
|
-
this._startPromise = this._startWithStateTransitions();
|
13373
|
-
return this._startPromise;
|
13374
|
-
}
|
13375
|
-
async _startWithStateTransitions() {
|
13376
|
-
if (this._connectionState !== HubConnectionState.Disconnected) {
|
13377
|
-
return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));
|
13378
|
-
}
|
13379
|
-
this._connectionState = HubConnectionState.Connecting;
|
13380
|
-
this._logger.log(LogLevel.Debug, "Starting HubConnection.");
|
13381
|
-
try {
|
13382
|
-
await this._startInternal();
|
13383
|
-
if (Platform.isBrowser) {
|
13384
|
-
// Log when the browser freezes the tab so users know why their connection unexpectedly stopped working
|
13385
|
-
window.document.addEventListener("freeze", this._freezeEventListener);
|
13386
|
-
}
|
13387
|
-
this._connectionState = HubConnectionState.Connected;
|
13388
|
-
this._connectionStarted = true;
|
13389
|
-
this._logger.log(LogLevel.Debug, "HubConnection connected successfully.");
|
13390
|
-
}
|
13391
|
-
catch (e) {
|
13392
|
-
this._connectionState = HubConnectionState.Disconnected;
|
13393
|
-
this._logger.log(LogLevel.Debug, `HubConnection failed to start successfully because of error '${e}'.`);
|
13394
|
-
return Promise.reject(e);
|
13395
|
-
}
|
13396
|
-
}
|
13397
|
-
async _startInternal() {
|
13398
|
-
this._stopDuringStartError = undefined;
|
13399
|
-
this._receivedHandshakeResponse = false;
|
13400
|
-
// Set up the promise before any connection is (re)started otherwise it could race with received messages
|
13401
|
-
const handshakePromise = new Promise((resolve, reject) => {
|
13402
|
-
this._handshakeResolver = resolve;
|
13403
|
-
this._handshakeRejecter = reject;
|
13404
|
-
});
|
13405
|
-
await this.connection.start(this._protocol.transferFormat);
|
13406
|
-
try {
|
13407
|
-
const handshakeRequest = {
|
13408
|
-
protocol: this._protocol.name,
|
13409
|
-
version: this._protocol.version,
|
13410
|
-
};
|
13411
|
-
this._logger.log(LogLevel.Debug, "Sending handshake request.");
|
13412
|
-
await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(handshakeRequest));
|
13413
|
-
this._logger.log(LogLevel.Information, `Using HubProtocol '${this._protocol.name}'.`);
|
13414
|
-
// defensively cleanup timeout in case we receive a message from the server before we finish start
|
13415
|
-
this._cleanupTimeout();
|
13416
|
-
this._resetTimeoutPeriod();
|
13417
|
-
this._resetKeepAliveInterval();
|
13418
|
-
await handshakePromise;
|
13419
|
-
// It's important to check the stopDuringStartError instead of just relying on the handshakePromise
|
13420
|
-
// being rejected on close, because this continuation can run after both the handshake completed successfully
|
13421
|
-
// and the connection was closed.
|
13422
|
-
if (this._stopDuringStartError) {
|
13423
|
-
// It's important to throw instead of returning a rejected promise, because we don't want to allow any state
|
13424
|
-
// transitions to occur between now and the calling code observing the exceptions. Returning a rejected promise
|
13425
|
-
// will cause the calling continuation to get scheduled to run later.
|
13426
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
13427
|
-
throw this._stopDuringStartError;
|
13428
|
-
}
|
13429
|
-
}
|
13430
|
-
catch (e) {
|
13431
|
-
this._logger.log(LogLevel.Debug, `Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`);
|
13432
|
-
this._cleanupTimeout();
|
13433
|
-
this._cleanupPingTimer();
|
13434
|
-
// HttpConnection.stop() should not complete until after the onclose callback is invoked.
|
13435
|
-
// This will transition the HubConnection to the disconnected state before HttpConnection.stop() completes.
|
13436
|
-
await this.connection.stop(e);
|
13437
|
-
throw e;
|
13438
|
-
}
|
13439
|
-
}
|
13440
|
-
/** Stops the connection.
|
13441
|
-
*
|
13442
|
-
* @returns {Promise<void>} A Promise that resolves when the connection has been successfully terminated, or rejects with an error.
|
13443
|
-
*/
|
13444
|
-
async stop() {
|
13445
|
-
// Capture the start promise before the connection might be restarted in an onclose callback.
|
13446
|
-
const startPromise = this._startPromise;
|
13447
|
-
this._stopPromise = this._stopInternal();
|
13448
|
-
await this._stopPromise;
|
13449
|
-
try {
|
13450
|
-
// Awaiting undefined continues immediately
|
13451
|
-
await startPromise;
|
13452
|
-
}
|
13453
|
-
catch (e) {
|
13454
|
-
// This exception is returned to the user as a rejected Promise from the start method.
|
13455
|
-
}
|
13456
|
-
}
|
13457
|
-
_stopInternal(error) {
|
13458
|
-
if (this._connectionState === HubConnectionState.Disconnected) {
|
13459
|
-
this._logger.log(LogLevel.Debug, `Call to HubConnection.stop(${error}) ignored because it is already in the disconnected state.`);
|
13460
|
-
return Promise.resolve();
|
13461
|
-
}
|
13462
|
-
if (this._connectionState === HubConnectionState.Disconnecting) {
|
13463
|
-
this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
|
13464
|
-
return this._stopPromise;
|
13465
|
-
}
|
13466
|
-
this._connectionState = HubConnectionState.Disconnecting;
|
13467
|
-
this._logger.log(LogLevel.Debug, "Stopping HubConnection.");
|
13468
|
-
if (this._reconnectDelayHandle) {
|
13469
|
-
// We're in a reconnect delay which means the underlying connection is currently already stopped.
|
13470
|
-
// Just clear the handle to stop the reconnect loop (which no one is waiting on thankfully) and
|
13471
|
-
// fire the onclose callbacks.
|
13472
|
-
this._logger.log(LogLevel.Debug, "Connection stopped during reconnect delay. Done reconnecting.");
|
13473
|
-
clearTimeout(this._reconnectDelayHandle);
|
13474
|
-
this._reconnectDelayHandle = undefined;
|
13475
|
-
this._completeClose();
|
13476
|
-
return Promise.resolve();
|
13477
|
-
}
|
13478
|
-
this._cleanupTimeout();
|
13479
|
-
this._cleanupPingTimer();
|
13480
|
-
this._stopDuringStartError = error || new Error("The connection was stopped before the hub handshake could complete.");
|
13481
|
-
// HttpConnection.stop() should not complete until after either HttpConnection.start() fails
|
13482
|
-
// or the onclose callback is invoked. The onclose callback will transition the HubConnection
|
13483
|
-
// to the disconnected state if need be before HttpConnection.stop() completes.
|
13484
|
-
return this.connection.stop(error);
|
13485
|
-
}
|
13486
|
-
/** Invokes a streaming hub method on the server using the specified name and arguments.
|
13487
|
-
*
|
13488
|
-
* @typeparam T The type of the items returned by the server.
|
13489
|
-
* @param {string} methodName The name of the server method to invoke.
|
13490
|
-
* @param {any[]} args The arguments used to invoke the server method.
|
13491
|
-
* @returns {IStreamResult<T>} An object that yields results from the server as they are received.
|
13492
|
-
*/
|
13493
|
-
stream(methodName, ...args) {
|
13494
|
-
const [streams, streamIds] = this._replaceStreamingParams(args);
|
13495
|
-
const invocationDescriptor = this._createStreamInvocation(methodName, args, streamIds);
|
13496
|
-
// eslint-disable-next-line prefer-const
|
13497
|
-
let promiseQueue;
|
13498
|
-
const subject = new Subject();
|
13499
|
-
subject.cancelCallback = () => {
|
13500
|
-
const cancelInvocation = this._createCancelInvocation(invocationDescriptor.invocationId);
|
13501
|
-
delete this._callbacks[invocationDescriptor.invocationId];
|
13502
|
-
return promiseQueue.then(() => {
|
13503
|
-
return this._sendWithProtocol(cancelInvocation);
|
13504
|
-
});
|
13505
|
-
};
|
13506
|
-
this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
|
13507
|
-
if (error) {
|
13508
|
-
subject.error(error);
|
13509
|
-
return;
|
13510
|
-
}
|
13511
|
-
else if (invocationEvent) {
|
13512
|
-
// invocationEvent will not be null when an error is not passed to the callback
|
13513
|
-
if (invocationEvent.type === MessageType.Completion) {
|
13514
|
-
if (invocationEvent.error) {
|
13515
|
-
subject.error(new Error(invocationEvent.error));
|
13516
|
-
}
|
13517
|
-
else {
|
13518
|
-
subject.complete();
|
13519
|
-
}
|
13520
|
-
}
|
13521
|
-
else {
|
13522
|
-
subject.next((invocationEvent.item));
|
13523
|
-
}
|
13524
|
-
}
|
13525
|
-
};
|
13526
|
-
promiseQueue = this._sendWithProtocol(invocationDescriptor)
|
13527
|
-
.catch((e) => {
|
13528
|
-
subject.error(e);
|
13529
|
-
delete this._callbacks[invocationDescriptor.invocationId];
|
13530
|
-
});
|
13531
|
-
this._launchStreams(streams, promiseQueue);
|
13532
|
-
return subject;
|
13533
|
-
}
|
13534
|
-
_sendMessage(message) {
|
13535
|
-
this._resetKeepAliveInterval();
|
13536
|
-
return this.connection.send(message);
|
13537
|
-
}
|
13538
|
-
/**
|
13539
|
-
* Sends a js object to the server.
|
13540
|
-
* @param message The js object to serialize and send.
|
13541
|
-
*/
|
13542
|
-
_sendWithProtocol(message) {
|
13543
|
-
return this._sendMessage(this._protocol.writeMessage(message));
|
13544
|
-
}
|
13545
|
-
/** Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
|
13546
|
-
*
|
13547
|
-
* The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still
|
13548
|
-
* be processing the invocation.
|
13549
|
-
*
|
13550
|
-
* @param {string} methodName The name of the server method to invoke.
|
13551
|
-
* @param {any[]} args The arguments used to invoke the server method.
|
13552
|
-
* @returns {Promise<void>} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
|
13553
|
-
*/
|
13554
|
-
send(methodName, ...args) {
|
13555
|
-
const [streams, streamIds] = this._replaceStreamingParams(args);
|
13556
|
-
const sendPromise = this._sendWithProtocol(this._createInvocation(methodName, args, true, streamIds));
|
13557
|
-
this._launchStreams(streams, sendPromise);
|
13558
|
-
return sendPromise;
|
13559
|
-
}
|
13560
|
-
/** Invokes a hub method on the server using the specified name and arguments.
|
13561
|
-
*
|
13562
|
-
* The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise
|
13563
|
-
* resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of
|
13564
|
-
* resolving the Promise.
|
13565
|
-
*
|
13566
|
-
* @typeparam T The expected return type.
|
13567
|
-
* @param {string} methodName The name of the server method to invoke.
|
13568
|
-
* @param {any[]} args The arguments used to invoke the server method.
|
13569
|
-
* @returns {Promise<T>} A Promise that resolves with the result of the server method (if any), or rejects with an error.
|
13570
|
-
*/
|
13571
|
-
invoke(methodName, ...args) {
|
13572
|
-
const [streams, streamIds] = this._replaceStreamingParams(args);
|
13573
|
-
const invocationDescriptor = this._createInvocation(methodName, args, false, streamIds);
|
13574
|
-
const p = new Promise((resolve, reject) => {
|
13575
|
-
// invocationId will always have a value for a non-blocking invocation
|
13576
|
-
this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
|
13577
|
-
if (error) {
|
13578
|
-
reject(error);
|
13579
|
-
return;
|
13580
|
-
}
|
13581
|
-
else if (invocationEvent) {
|
13582
|
-
// invocationEvent will not be null when an error is not passed to the callback
|
13583
|
-
if (invocationEvent.type === MessageType.Completion) {
|
13584
|
-
if (invocationEvent.error) {
|
13585
|
-
reject(new Error(invocationEvent.error));
|
13586
|
-
}
|
13587
|
-
else {
|
13588
|
-
resolve(invocationEvent.result);
|
13589
|
-
}
|
13590
|
-
}
|
13591
|
-
else {
|
13592
|
-
reject(new Error(`Unexpected message type: ${invocationEvent.type}`));
|
13593
|
-
}
|
13594
|
-
}
|
13595
|
-
};
|
13596
|
-
const promiseQueue = this._sendWithProtocol(invocationDescriptor)
|
13597
|
-
.catch((e) => {
|
13598
|
-
reject(e);
|
13599
|
-
// invocationId will always have a value for a non-blocking invocation
|
13600
|
-
delete this._callbacks[invocationDescriptor.invocationId];
|
13601
|
-
});
|
13602
|
-
this._launchStreams(streams, promiseQueue);
|
13603
|
-
});
|
13604
|
-
return p;
|
13605
|
-
}
|
13606
|
-
/** Registers a handler that will be invoked when the hub method with the specified method name is invoked.
|
13607
|
-
*
|
13608
|
-
* @param {string} methodName The name of the hub method to define.
|
13609
|
-
* @param {Function} newMethod The handler that will be raised when the hub method is invoked.
|
13610
|
-
*/
|
13611
|
-
on(methodName, newMethod) {
|
13612
|
-
if (!methodName || !newMethod) {
|
13613
|
-
return;
|
13614
|
-
}
|
13615
|
-
methodName = methodName.toLowerCase();
|
13616
|
-
if (!this._methods[methodName]) {
|
13617
|
-
this._methods[methodName] = [];
|
13618
|
-
}
|
13619
|
-
// Preventing adding the same handler multiple times.
|
13620
|
-
if (this._methods[methodName].indexOf(newMethod) !== -1) {
|
13621
|
-
return;
|
13622
|
-
}
|
13623
|
-
this._methods[methodName].push(newMethod);
|
13624
|
-
}
|
13625
|
-
off(methodName, method) {
|
13626
|
-
if (!methodName) {
|
13627
|
-
return;
|
13628
|
-
}
|
13629
|
-
methodName = methodName.toLowerCase();
|
13630
|
-
const handlers = this._methods[methodName];
|
13631
|
-
if (!handlers) {
|
13632
|
-
return;
|
13633
|
-
}
|
13634
|
-
if (method) {
|
13635
|
-
const removeIdx = handlers.indexOf(method);
|
13636
|
-
if (removeIdx !== -1) {
|
13637
|
-
handlers.splice(removeIdx, 1);
|
13638
|
-
if (handlers.length === 0) {
|
13639
|
-
delete this._methods[methodName];
|
13640
|
-
}
|
13641
|
-
}
|
13642
|
-
}
|
13643
|
-
else {
|
13644
|
-
delete this._methods[methodName];
|
13645
|
-
}
|
13646
|
-
}
|
13647
|
-
/** Registers a handler that will be invoked when the connection is closed.
|
13648
|
-
*
|
13649
|
-
* @param {Function} callback The handler that will be invoked when the connection is closed. Optionally receives a single argument containing the error that caused the connection to close (if any).
|
13650
|
-
*/
|
13651
|
-
onclose(callback) {
|
13652
|
-
if (callback) {
|
13653
|
-
this._closedCallbacks.push(callback);
|
13654
|
-
}
|
13655
|
-
}
|
13656
|
-
/** Registers a handler that will be invoked when the connection starts reconnecting.
|
13657
|
-
*
|
13658
|
-
* @param {Function} callback The handler that will be invoked when the connection starts reconnecting. Optionally receives a single argument containing the error that caused the connection to start reconnecting (if any).
|
13659
|
-
*/
|
13660
|
-
onreconnecting(callback) {
|
13661
|
-
if (callback) {
|
13662
|
-
this._reconnectingCallbacks.push(callback);
|
13663
|
-
}
|
13664
|
-
}
|
13665
|
-
/** Registers a handler that will be invoked when the connection successfully reconnects.
|
13666
|
-
*
|
13667
|
-
* @param {Function} callback The handler that will be invoked when the connection successfully reconnects.
|
13668
|
-
*/
|
13669
|
-
onreconnected(callback) {
|
13670
|
-
if (callback) {
|
13671
|
-
this._reconnectedCallbacks.push(callback);
|
13672
|
-
}
|
13673
|
-
}
|
13674
|
-
_processIncomingData(data) {
|
13675
|
-
this._cleanupTimeout();
|
13676
|
-
if (!this._receivedHandshakeResponse) {
|
13677
|
-
data = this._processHandshakeResponse(data);
|
13678
|
-
this._receivedHandshakeResponse = true;
|
13679
|
-
}
|
13680
|
-
// Data may have all been read when processing handshake response
|
13681
|
-
if (data) {
|
13682
|
-
// Parse the messages
|
13683
|
-
const messages = this._protocol.parseMessages(data, this._logger);
|
13684
|
-
for (const message of messages) {
|
13685
|
-
switch (message.type) {
|
13686
|
-
case MessageType.Invocation:
|
13687
|
-
this._invokeClientMethod(message);
|
13688
|
-
break;
|
13689
|
-
case MessageType.StreamItem:
|
13690
|
-
case MessageType.Completion: {
|
13691
|
-
const callback = this._callbacks[message.invocationId];
|
13692
|
-
if (callback) {
|
13693
|
-
if (message.type === MessageType.Completion) {
|
13694
|
-
delete this._callbacks[message.invocationId];
|
13695
|
-
}
|
13696
|
-
try {
|
13697
|
-
callback(message);
|
13698
|
-
}
|
13699
|
-
catch (e) {
|
13700
|
-
this._logger.log(LogLevel.Error, `Stream callback threw error: ${getErrorString(e)}`);
|
13701
|
-
}
|
13702
|
-
}
|
13703
|
-
break;
|
13704
|
-
}
|
13705
|
-
case MessageType.Ping:
|
13706
|
-
// Don't care about pings
|
13707
|
-
break;
|
13708
|
-
case MessageType.Close: {
|
13709
|
-
this._logger.log(LogLevel.Information, "Close message received from server.");
|
13710
|
-
const error = message.error ? new Error("Server returned an error on close: " + message.error) : undefined;
|
13711
|
-
if (message.allowReconnect === true) {
|
13712
|
-
// It feels wrong not to await connection.stop() here, but processIncomingData is called as part of an onreceive callback which is not async,
|
13713
|
-
// this is already the behavior for serverTimeout(), and HttpConnection.Stop() should catch and log all possible exceptions.
|
13714
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
13715
|
-
this.connection.stop(error);
|
13716
|
-
}
|
13717
|
-
else {
|
13718
|
-
// We cannot await stopInternal() here, but subsequent calls to stop() will await this if stopInternal() is still ongoing.
|
13719
|
-
this._stopPromise = this._stopInternal(error);
|
13720
|
-
}
|
13721
|
-
break;
|
13722
|
-
}
|
13723
|
-
default:
|
13724
|
-
this._logger.log(LogLevel.Warning, `Invalid message type: ${message.type}.`);
|
13725
|
-
break;
|
13726
|
-
}
|
13727
|
-
}
|
13728
|
-
}
|
13729
|
-
this._resetTimeoutPeriod();
|
13730
|
-
}
|
13731
|
-
_processHandshakeResponse(data) {
|
13732
|
-
let responseMessage;
|
13733
|
-
let remainingData;
|
13734
|
-
try {
|
13735
|
-
[remainingData, responseMessage] = this._handshakeProtocol.parseHandshakeResponse(data);
|
13736
|
-
}
|
13737
|
-
catch (e) {
|
13738
|
-
const message = "Error parsing handshake response: " + e;
|
13739
|
-
this._logger.log(LogLevel.Error, message);
|
13740
|
-
const error = new Error(message);
|
13741
|
-
this._handshakeRejecter(error);
|
13742
|
-
throw error;
|
13743
|
-
}
|
13744
|
-
if (responseMessage.error) {
|
13745
|
-
const message = "Server returned handshake error: " + responseMessage.error;
|
13746
|
-
this._logger.log(LogLevel.Error, message);
|
13747
|
-
const error = new Error(message);
|
13748
|
-
this._handshakeRejecter(error);
|
13749
|
-
throw error;
|
13750
|
-
}
|
13751
|
-
else {
|
13752
|
-
this._logger.log(LogLevel.Debug, "Server handshake complete.");
|
13753
|
-
}
|
13754
|
-
this._handshakeResolver();
|
13755
|
-
return remainingData;
|
13756
|
-
}
|
13757
|
-
_resetKeepAliveInterval() {
|
13758
|
-
if (this.connection.features.inherentKeepAlive) {
|
13759
|
-
return;
|
13760
|
-
}
|
13761
|
-
// Set the time we want the next keep alive to be sent
|
13762
|
-
// Timer will be setup on next message receive
|
13763
|
-
this._nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds;
|
13764
|
-
this._cleanupPingTimer();
|
13765
|
-
}
|
13766
|
-
_resetTimeoutPeriod() {
|
13767
|
-
if (!this.connection.features || !this.connection.features.inherentKeepAlive) {
|
13768
|
-
// Set the timeout timer
|
13769
|
-
this._timeoutHandle = setTimeout(() => this.serverTimeout(), this.serverTimeoutInMilliseconds);
|
13770
|
-
// Set keepAlive timer if there isn't one
|
13771
|
-
if (this._pingServerHandle === undefined) {
|
13772
|
-
let nextPing = this._nextKeepAlive - new Date().getTime();
|
13773
|
-
if (nextPing < 0) {
|
13774
|
-
nextPing = 0;
|
13775
|
-
}
|
13776
|
-
// The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute
|
13777
|
-
this._pingServerHandle = setTimeout(async () => {
|
13778
|
-
if (this._connectionState === HubConnectionState.Connected) {
|
13779
|
-
try {
|
13780
|
-
await this._sendMessage(this._cachedPingMessage);
|
13781
|
-
}
|
13782
|
-
catch {
|
13783
|
-
// We don't care about the error. It should be seen elsewhere in the client.
|
13784
|
-
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering
|
13785
|
-
this._cleanupPingTimer();
|
13786
|
-
}
|
13787
|
-
}
|
13788
|
-
}, nextPing);
|
13789
|
-
}
|
13790
|
-
}
|
13791
|
-
}
|
13792
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
13793
|
-
serverTimeout() {
|
13794
|
-
// The server hasn't talked to us in a while. It doesn't like us anymore ... :(
|
13795
|
-
// Terminate the connection, but we don't need to wait on the promise. This could trigger reconnecting.
|
13796
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
13797
|
-
this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."));
|
13798
|
-
}
|
13799
|
-
_invokeClientMethod(invocationMessage) {
|
13800
|
-
const methods = this._methods[invocationMessage.target.toLowerCase()];
|
13801
|
-
if (methods) {
|
13802
|
-
try {
|
13803
|
-
methods.forEach((m) => m.apply(this, invocationMessage.arguments));
|
13804
|
-
}
|
13805
|
-
catch (e) {
|
13806
|
-
this._logger.log(LogLevel.Error, `A callback for the method ${invocationMessage.target.toLowerCase()} threw error '${e}'.`);
|
13807
|
-
}
|
13808
|
-
if (invocationMessage.invocationId) {
|
13809
|
-
// This is not supported in v1. So we return an error to avoid blocking the server waiting for the response.
|
13810
|
-
const message = "Server requested a response, which is not supported in this version of the client.";
|
13811
|
-
this._logger.log(LogLevel.Error, message);
|
13812
|
-
// We don't want to wait on the stop itself.
|
13813
|
-
this._stopPromise = this._stopInternal(new Error(message));
|
13814
|
-
}
|
13815
|
-
}
|
13816
|
-
else {
|
13817
|
-
this._logger.log(LogLevel.Warning, `No client method with the name '${invocationMessage.target}' found.`);
|
13818
|
-
}
|
13819
|
-
}
|
13820
|
-
_connectionClosed(error) {
|
13821
|
-
this._logger.log(LogLevel.Debug, `HubConnection.connectionClosed(${error}) called while in state ${this._connectionState}.`);
|
13822
|
-
// Triggering this.handshakeRejecter is insufficient because it could already be resolved without the continuation having run yet.
|
13823
|
-
this._stopDuringStartError = this._stopDuringStartError || error || new Error("The underlying connection was closed before the hub handshake could complete.");
|
13824
|
-
// If the handshake is in progress, start will be waiting for the handshake promise, so we complete it.
|
13825
|
-
// If it has already completed, this should just noop.
|
13826
|
-
if (this._handshakeResolver) {
|
13827
|
-
this._handshakeResolver();
|
13828
|
-
}
|
13829
|
-
this._cancelCallbacksWithError(error || new Error("Invocation canceled due to the underlying connection being closed."));
|
13830
|
-
this._cleanupTimeout();
|
13831
|
-
this._cleanupPingTimer();
|
13832
|
-
if (this._connectionState === HubConnectionState.Disconnecting) {
|
13833
|
-
this._completeClose(error);
|
13834
|
-
}
|
13835
|
-
else if (this._connectionState === HubConnectionState.Connected && this._reconnectPolicy) {
|
13836
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
13837
|
-
this._reconnect(error);
|
13838
|
-
}
|
13839
|
-
else if (this._connectionState === HubConnectionState.Connected) {
|
13840
|
-
this._completeClose(error);
|
13841
|
-
}
|
13842
|
-
// If none of the above if conditions were true were called the HubConnection must be in either:
|
13843
|
-
// 1. The Connecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail it.
|
13844
|
-
// 2. The Reconnecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail the current reconnect attempt
|
13845
|
-
// and potentially continue the reconnect() loop.
|
13846
|
-
// 3. The Disconnected state in which case we're already done.
|
13847
|
-
}
|
13848
|
-
_completeClose(error) {
|
13849
|
-
if (this._connectionStarted) {
|
13850
|
-
this._connectionState = HubConnectionState.Disconnected;
|
13851
|
-
this._connectionStarted = false;
|
13852
|
-
if (Platform.isBrowser) {
|
13853
|
-
window.document.removeEventListener("freeze", this._freezeEventListener);
|
13854
|
-
}
|
13855
|
-
try {
|
13856
|
-
this._closedCallbacks.forEach((c) => c.apply(this, [error]));
|
13857
|
-
}
|
13858
|
-
catch (e) {
|
13859
|
-
this._logger.log(LogLevel.Error, `An onclose callback called with error '${error}' threw error '${e}'.`);
|
13860
|
-
}
|
13861
|
-
}
|
13862
|
-
}
|
13863
|
-
async _reconnect(error) {
|
13864
|
-
const reconnectStartTime = Date.now();
|
13865
|
-
let previousReconnectAttempts = 0;
|
13866
|
-
let retryError = error !== undefined ? error : new Error("Attempting to reconnect due to a unknown error.");
|
13867
|
-
let nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, 0, retryError);
|
13868
|
-
if (nextRetryDelay === null) {
|
13869
|
-
this._logger.log(LogLevel.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.");
|
13870
|
-
this._completeClose(error);
|
13871
|
-
return;
|
13872
|
-
}
|
13873
|
-
this._connectionState = HubConnectionState.Reconnecting;
|
13874
|
-
if (error) {
|
13875
|
-
this._logger.log(LogLevel.Information, `Connection reconnecting because of error '${error}'.`);
|
13876
|
-
}
|
13877
|
-
else {
|
13878
|
-
this._logger.log(LogLevel.Information, "Connection reconnecting.");
|
13879
|
-
}
|
13880
|
-
if (this._reconnectingCallbacks.length !== 0) {
|
13881
|
-
try {
|
13882
|
-
this._reconnectingCallbacks.forEach((c) => c.apply(this, [error]));
|
13883
|
-
}
|
13884
|
-
catch (e) {
|
13885
|
-
this._logger.log(LogLevel.Error, `An onreconnecting callback called with error '${error}' threw error '${e}'.`);
|
13886
|
-
}
|
13887
|
-
// Exit early if an onreconnecting callback called connection.stop().
|
13888
|
-
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
13889
|
-
this._logger.log(LogLevel.Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
|
13890
|
-
return;
|
13891
|
-
}
|
13892
|
-
}
|
13893
|
-
while (nextRetryDelay !== null) {
|
13894
|
-
this._logger.log(LogLevel.Information, `Reconnect attempt number ${previousReconnectAttempts} will start in ${nextRetryDelay} ms.`);
|
13895
|
-
await new Promise((resolve) => {
|
13896
|
-
this._reconnectDelayHandle = setTimeout(resolve, nextRetryDelay);
|
13897
|
-
});
|
13898
|
-
this._reconnectDelayHandle = undefined;
|
13899
|
-
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
13900
|
-
this._logger.log(LogLevel.Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
|
13901
|
-
return;
|
13902
|
-
}
|
13903
|
-
try {
|
13904
|
-
await this._startInternal();
|
13905
|
-
this._connectionState = HubConnectionState.Connected;
|
13906
|
-
this._logger.log(LogLevel.Information, "HubConnection reconnected successfully.");
|
13907
|
-
if (this._reconnectedCallbacks.length !== 0) {
|
13908
|
-
try {
|
13909
|
-
this._reconnectedCallbacks.forEach((c) => c.apply(this, [this.connection.connectionId]));
|
13910
|
-
}
|
13911
|
-
catch (e) {
|
13912
|
-
this._logger.log(LogLevel.Error, `An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`);
|
13913
|
-
}
|
13914
|
-
}
|
13915
|
-
return;
|
13916
|
-
}
|
13917
|
-
catch (e) {
|
13918
|
-
this._logger.log(LogLevel.Information, `Reconnect attempt failed because of error '${e}'.`);
|
13919
|
-
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
13920
|
-
this._logger.log(LogLevel.Debug, `Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`);
|
13921
|
-
// The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong.
|
13922
|
-
if (this._connectionState === HubConnectionState.Disconnecting) {
|
13923
|
-
this._completeClose();
|
13924
|
-
}
|
13925
|
-
return;
|
13926
|
-
}
|
13927
|
-
retryError = e instanceof Error ? e : new Error(e.toString());
|
13928
|
-
nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, Date.now() - reconnectStartTime, retryError);
|
13929
|
-
}
|
13930
|
-
}
|
13931
|
-
this._logger.log(LogLevel.Information, `Reconnect retries have been exhausted after ${Date.now() - reconnectStartTime} ms and ${previousReconnectAttempts} failed attempts. Connection disconnecting.`);
|
13932
|
-
this._completeClose();
|
13933
|
-
}
|
13934
|
-
_getNextRetryDelay(previousRetryCount, elapsedMilliseconds, retryReason) {
|
13935
|
-
try {
|
13936
|
-
return this._reconnectPolicy.nextRetryDelayInMilliseconds({
|
13937
|
-
elapsedMilliseconds,
|
13938
|
-
previousRetryCount,
|
13939
|
-
retryReason,
|
13940
|
-
});
|
13941
|
-
}
|
13942
|
-
catch (e) {
|
13943
|
-
this._logger.log(LogLevel.Error, `IRetryPolicy.nextRetryDelayInMilliseconds(${previousRetryCount}, ${elapsedMilliseconds}) threw error '${e}'.`);
|
13944
|
-
return null;
|
13945
|
-
}
|
13946
|
-
}
|
13947
|
-
_cancelCallbacksWithError(error) {
|
13948
|
-
const callbacks = this._callbacks;
|
13949
|
-
this._callbacks = {};
|
13950
|
-
Object.keys(callbacks)
|
13951
|
-
.forEach((key) => {
|
13952
|
-
const callback = callbacks[key];
|
13953
|
-
try {
|
13954
|
-
callback(null, error);
|
13955
|
-
}
|
13956
|
-
catch (e) {
|
13957
|
-
this._logger.log(LogLevel.Error, `Stream 'error' callback called with '${error}' threw error: ${getErrorString(e)}`);
|
13958
|
-
}
|
13959
|
-
});
|
13960
|
-
}
|
13961
|
-
_cleanupPingTimer() {
|
13962
|
-
if (this._pingServerHandle) {
|
13963
|
-
clearTimeout(this._pingServerHandle);
|
13964
|
-
this._pingServerHandle = undefined;
|
13965
|
-
}
|
13966
|
-
}
|
13967
|
-
_cleanupTimeout() {
|
13968
|
-
if (this._timeoutHandle) {
|
13969
|
-
clearTimeout(this._timeoutHandle);
|
13970
|
-
}
|
13971
|
-
}
|
13972
|
-
_createInvocation(methodName, args, nonblocking, streamIds) {
|
13973
|
-
if (nonblocking) {
|
13974
|
-
if (streamIds.length !== 0) {
|
13975
|
-
return {
|
13976
|
-
arguments: args,
|
13977
|
-
streamIds,
|
13978
|
-
target: methodName,
|
13979
|
-
type: MessageType.Invocation,
|
13980
|
-
};
|
13981
|
-
}
|
13982
|
-
else {
|
13983
|
-
return {
|
13984
|
-
arguments: args,
|
13985
|
-
target: methodName,
|
13986
|
-
type: MessageType.Invocation,
|
13987
|
-
};
|
13988
|
-
}
|
13989
|
-
}
|
13990
|
-
else {
|
13991
|
-
const invocationId = this._invocationId;
|
13992
|
-
this._invocationId++;
|
13993
|
-
if (streamIds.length !== 0) {
|
13994
|
-
return {
|
13995
|
-
arguments: args,
|
13996
|
-
invocationId: invocationId.toString(),
|
13997
|
-
streamIds,
|
13998
|
-
target: methodName,
|
13999
|
-
type: MessageType.Invocation,
|
14000
|
-
};
|
14001
|
-
}
|
14002
|
-
else {
|
14003
|
-
return {
|
14004
|
-
arguments: args,
|
14005
|
-
invocationId: invocationId.toString(),
|
14006
|
-
target: methodName,
|
14007
|
-
type: MessageType.Invocation,
|
14008
|
-
};
|
14009
|
-
}
|
14010
|
-
}
|
14011
|
-
}
|
14012
|
-
_launchStreams(streams, promiseQueue) {
|
14013
|
-
if (streams.length === 0) {
|
14014
|
-
return;
|
14015
|
-
}
|
14016
|
-
// Synchronize stream data so they arrive in-order on the server
|
14017
|
-
if (!promiseQueue) {
|
14018
|
-
promiseQueue = Promise.resolve();
|
14019
|
-
}
|
14020
|
-
// We want to iterate over the keys, since the keys are the stream ids
|
14021
|
-
// eslint-disable-next-line guard-for-in
|
14022
|
-
for (const streamId in streams) {
|
14023
|
-
streams[streamId].subscribe({
|
14024
|
-
complete: () => {
|
14025
|
-
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId)));
|
14026
|
-
},
|
14027
|
-
error: (err) => {
|
14028
|
-
let message;
|
14029
|
-
if (err instanceof Error) {
|
14030
|
-
message = err.message;
|
14031
|
-
}
|
14032
|
-
else if (err && err.toString) {
|
14033
|
-
message = err.toString();
|
14034
|
-
}
|
14035
|
-
else {
|
14036
|
-
message = "Unknown error";
|
14037
|
-
}
|
14038
|
-
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId, message)));
|
14039
|
-
},
|
14040
|
-
next: (item) => {
|
14041
|
-
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createStreamItemMessage(streamId, item)));
|
14042
|
-
},
|
14043
|
-
});
|
14044
|
-
}
|
14045
|
-
}
|
14046
|
-
_replaceStreamingParams(args) {
|
14047
|
-
const streams = [];
|
14048
|
-
const streamIds = [];
|
14049
|
-
for (let i = 0; i < args.length; i++) {
|
14050
|
-
const argument = args[i];
|
14051
|
-
if (this._isObservable(argument)) {
|
14052
|
-
const streamId = this._invocationId;
|
14053
|
-
this._invocationId++;
|
14054
|
-
// Store the stream for later use
|
14055
|
-
streams[streamId] = argument;
|
14056
|
-
streamIds.push(streamId.toString());
|
14057
|
-
// remove stream from args
|
14058
|
-
args.splice(i, 1);
|
14059
|
-
}
|
14060
|
-
}
|
14061
|
-
return [streams, streamIds];
|
14062
|
-
}
|
14063
|
-
_isObservable(arg) {
|
14064
|
-
// This allows other stream implementations to just work (like rxjs)
|
14065
|
-
return arg && arg.subscribe && typeof arg.subscribe === "function";
|
14066
|
-
}
|
14067
|
-
_createStreamInvocation(methodName, args, streamIds) {
|
14068
|
-
const invocationId = this._invocationId;
|
14069
|
-
this._invocationId++;
|
14070
|
-
if (streamIds.length !== 0) {
|
14071
|
-
return {
|
14072
|
-
arguments: args,
|
14073
|
-
invocationId: invocationId.toString(),
|
14074
|
-
streamIds,
|
14075
|
-
target: methodName,
|
14076
|
-
type: MessageType.StreamInvocation,
|
14077
|
-
};
|
14078
|
-
}
|
14079
|
-
else {
|
14080
|
-
return {
|
14081
|
-
arguments: args,
|
14082
|
-
invocationId: invocationId.toString(),
|
14083
|
-
target: methodName,
|
14084
|
-
type: MessageType.StreamInvocation,
|
14085
|
-
};
|
14086
|
-
}
|
14087
|
-
}
|
14088
|
-
_createCancelInvocation(id) {
|
14089
|
-
return {
|
14090
|
-
invocationId: id,
|
14091
|
-
type: MessageType.CancelInvocation,
|
14092
|
-
};
|
14093
|
-
}
|
14094
|
-
_createStreamItemMessage(id, item) {
|
14095
|
-
return {
|
14096
|
-
invocationId: id,
|
14097
|
-
item,
|
14098
|
-
type: MessageType.StreamItem,
|
14099
|
-
};
|
14100
|
-
}
|
14101
|
-
_createCompletionMessage(id, error, result) {
|
14102
|
-
if (error) {
|
14103
|
-
return {
|
14104
|
-
error,
|
14105
|
-
invocationId: id,
|
14106
|
-
type: MessageType.Completion,
|
14107
|
-
};
|
14108
|
-
}
|
14109
|
-
return {
|
14110
|
-
invocationId: id,
|
14111
|
-
result,
|
14112
|
-
type: MessageType.Completion,
|
14113
|
-
};
|
14114
|
-
}
|
14115
|
-
}
|
14116
|
-
|
14117
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14118
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
14119
|
-
// 0, 2, 10, 30 second delays before reconnect attempts.
|
14120
|
-
const DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];
|
14121
|
-
/** @private */
|
14122
|
-
class DefaultReconnectPolicy {
|
14123
|
-
constructor(retryDelays) {
|
14124
|
-
this._retryDelays = retryDelays !== undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;
|
14125
|
-
}
|
14126
|
-
nextRetryDelayInMilliseconds(retryContext) {
|
14127
|
-
return this._retryDelays[retryContext.previousRetryCount];
|
14128
|
-
}
|
14129
|
-
}
|
14130
|
-
|
14131
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14132
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
14133
|
-
class HeaderNames {
|
14134
|
-
}
|
14135
|
-
HeaderNames.Authorization = "Authorization";
|
14136
|
-
HeaderNames.Cookie = "Cookie";
|
14137
|
-
|
14138
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14139
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
14140
|
-
// This will be treated as a bit flag in the future, so we keep it using power-of-two values.
|
14141
|
-
/** Specifies a specific HTTP transport type. */
|
14142
|
-
var HttpTransportType;
|
14143
|
-
(function (HttpTransportType) {
|
14144
|
-
/** Specifies no transport preference. */
|
14145
|
-
HttpTransportType[HttpTransportType["None"] = 0] = "None";
|
14146
|
-
/** Specifies the WebSockets transport. */
|
14147
|
-
HttpTransportType[HttpTransportType["WebSockets"] = 1] = "WebSockets";
|
14148
|
-
/** Specifies the Server-Sent Events transport. */
|
14149
|
-
HttpTransportType[HttpTransportType["ServerSentEvents"] = 2] = "ServerSentEvents";
|
14150
|
-
/** Specifies the Long Polling transport. */
|
14151
|
-
HttpTransportType[HttpTransportType["LongPolling"] = 4] = "LongPolling";
|
14152
|
-
})(HttpTransportType || (HttpTransportType = {}));
|
14153
|
-
/** Specifies the transfer format for a connection. */
|
14154
|
-
var TransferFormat;
|
14155
|
-
(function (TransferFormat) {
|
14156
|
-
/** Specifies that only text data will be transmitted over the connection. */
|
14157
|
-
TransferFormat[TransferFormat["Text"] = 1] = "Text";
|
14158
|
-
/** Specifies that binary data will be transmitted over the connection. */
|
14159
|
-
TransferFormat[TransferFormat["Binary"] = 2] = "Binary";
|
14160
|
-
})(TransferFormat || (TransferFormat = {}));
|
14161
|
-
|
14162
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14163
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
14164
|
-
// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
14165
|
-
// We don't actually ever use the API being polyfilled, we always use the polyfill because
|
14166
|
-
// it's a very new API right now.
|
14167
|
-
// Not exported from index.
|
14168
|
-
/** @private */
|
14169
|
-
class AbortController$1 {
|
14170
|
-
constructor() {
|
14171
|
-
this._isAborted = false;
|
14172
|
-
this.onabort = null;
|
14173
|
-
}
|
14174
|
-
abort() {
|
14175
|
-
if (!this._isAborted) {
|
14176
|
-
this._isAborted = true;
|
14177
|
-
if (this.onabort) {
|
14178
|
-
this.onabort();
|
14179
|
-
}
|
14180
|
-
}
|
14181
|
-
}
|
14182
|
-
get signal() {
|
14183
|
-
return this;
|
14184
|
-
}
|
14185
|
-
get aborted() {
|
14186
|
-
return this._isAborted;
|
14187
|
-
}
|
14188
|
-
}
|
14189
|
-
|
14190
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14191
|
-
// Not exported from 'index', this type is internal.
|
14192
|
-
/** @private */
|
14193
|
-
class LongPollingTransport {
|
14194
|
-
constructor(httpClient, accessTokenFactory, logger, options) {
|
14195
|
-
this._httpClient = httpClient;
|
14196
|
-
this._accessTokenFactory = accessTokenFactory;
|
14197
|
-
this._logger = logger;
|
14198
|
-
this._pollAbort = new AbortController$1();
|
14199
|
-
this._options = options;
|
14200
|
-
this._running = false;
|
14201
|
-
this.onreceive = null;
|
14202
|
-
this.onclose = null;
|
14203
|
-
}
|
14204
|
-
// This is an internal type, not exported from 'index' so this is really just internal.
|
14205
|
-
get pollAborted() {
|
14206
|
-
return this._pollAbort.aborted;
|
14207
|
-
}
|
14208
|
-
async connect(url, transferFormat) {
|
14209
|
-
Arg.isRequired(url, "url");
|
14210
|
-
Arg.isRequired(transferFormat, "transferFormat");
|
14211
|
-
Arg.isIn(transferFormat, TransferFormat, "transferFormat");
|
14212
|
-
this._url = url;
|
14213
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Connecting.");
|
14214
|
-
// Allow binary format on Node and Browsers that support binary content (indicated by the presence of responseType property)
|
14215
|
-
if (transferFormat === TransferFormat.Binary &&
|
14216
|
-
(typeof XMLHttpRequest !== "undefined" && typeof new XMLHttpRequest().responseType !== "string")) {
|
14217
|
-
throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
|
14218
|
-
}
|
14219
|
-
const [name, value] = getUserAgentHeader();
|
14220
|
-
const headers = { [name]: value, ...this._options.headers };
|
14221
|
-
const pollOptions = {
|
14222
|
-
abortSignal: this._pollAbort.signal,
|
14223
|
-
headers,
|
14224
|
-
timeout: 100000,
|
14225
|
-
withCredentials: this._options.withCredentials,
|
14226
|
-
};
|
14227
|
-
if (transferFormat === TransferFormat.Binary) {
|
14228
|
-
pollOptions.responseType = "arraybuffer";
|
14229
|
-
}
|
14230
|
-
const token = await this._getAccessToken();
|
14231
|
-
this._updateHeaderToken(pollOptions, token);
|
14232
|
-
// Make initial long polling request
|
14233
|
-
// Server uses first long polling request to finish initializing connection and it returns without data
|
14234
|
-
const pollUrl = `${url}&_=${Date.now()}`;
|
14235
|
-
this._logger.log(LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
|
14236
|
-
const response = await this._httpClient.get(pollUrl, pollOptions);
|
14237
|
-
if (response.statusCode !== 200) {
|
14238
|
-
this._logger.log(LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
|
14239
|
-
// Mark running as false so that the poll immediately ends and runs the close logic
|
14240
|
-
this._closeError = new HttpError(response.statusText || "", response.statusCode);
|
14241
|
-
this._running = false;
|
14242
|
-
}
|
14243
|
-
else {
|
14244
|
-
this._running = true;
|
14245
|
-
}
|
14246
|
-
this._receiving = this._poll(this._url, pollOptions);
|
14247
|
-
}
|
14248
|
-
async _getAccessToken() {
|
14249
|
-
if (this._accessTokenFactory) {
|
14250
|
-
return await this._accessTokenFactory();
|
14251
|
-
}
|
14252
|
-
return null;
|
14253
|
-
}
|
14254
|
-
_updateHeaderToken(request, token) {
|
14255
|
-
if (!request.headers) {
|
14256
|
-
request.headers = {};
|
14257
|
-
}
|
14258
|
-
if (token) {
|
14259
|
-
request.headers[HeaderNames.Authorization] = `Bearer ${token}`;
|
14260
|
-
return;
|
14261
|
-
}
|
14262
|
-
if (request.headers[HeaderNames.Authorization]) {
|
14263
|
-
delete request.headers[HeaderNames.Authorization];
|
14264
|
-
}
|
14265
|
-
}
|
14266
|
-
async _poll(url, pollOptions) {
|
14267
|
-
try {
|
14268
|
-
while (this._running) {
|
14269
|
-
// We have to get the access token on each poll, in case it changes
|
14270
|
-
const token = await this._getAccessToken();
|
14271
|
-
this._updateHeaderToken(pollOptions, token);
|
14272
|
-
try {
|
14273
|
-
const pollUrl = `${url}&_=${Date.now()}`;
|
14274
|
-
this._logger.log(LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
|
14275
|
-
const response = await this._httpClient.get(pollUrl, pollOptions);
|
14276
|
-
if (response.statusCode === 204) {
|
14277
|
-
this._logger.log(LogLevel.Information, "(LongPolling transport) Poll terminated by server.");
|
14278
|
-
this._running = false;
|
14279
|
-
}
|
14280
|
-
else if (response.statusCode !== 200) {
|
14281
|
-
this._logger.log(LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
|
14282
|
-
// Unexpected status code
|
14283
|
-
this._closeError = new HttpError(response.statusText || "", response.statusCode);
|
14284
|
-
this._running = false;
|
14285
|
-
}
|
14286
|
-
else {
|
14287
|
-
// Process the response
|
14288
|
-
if (response.content) {
|
14289
|
-
this._logger.log(LogLevel.Trace, `(LongPolling transport) data received. ${getDataDetail(response.content, this._options.logMessageContent)}.`);
|
14290
|
-
if (this.onreceive) {
|
14291
|
-
this.onreceive(response.content);
|
14292
|
-
}
|
14293
|
-
}
|
14294
|
-
else {
|
14295
|
-
// This is another way timeout manifest.
|
14296
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
|
14297
|
-
}
|
14298
|
-
}
|
14299
|
-
}
|
14300
|
-
catch (e) {
|
14301
|
-
if (!this._running) {
|
14302
|
-
// Log but disregard errors that occur after stopping
|
14303
|
-
this._logger.log(LogLevel.Trace, `(LongPolling transport) Poll errored after shutdown: ${e.message}`);
|
14304
|
-
}
|
14305
|
-
else {
|
14306
|
-
if (e instanceof TimeoutError) {
|
14307
|
-
// Ignore timeouts and reissue the poll.
|
14308
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
|
14309
|
-
}
|
14310
|
-
else {
|
14311
|
-
// Close the connection with the error as the result.
|
14312
|
-
this._closeError = e;
|
14313
|
-
this._running = false;
|
14314
|
-
}
|
14315
|
-
}
|
14316
|
-
}
|
14317
|
-
}
|
14318
|
-
}
|
14319
|
-
finally {
|
14320
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Polling complete.");
|
14321
|
-
// We will reach here with pollAborted==false when the server returned a response causing the transport to stop.
|
14322
|
-
// If pollAborted==true then client initiated the stop and the stop method will raise the close event after DELETE is sent.
|
14323
|
-
if (!this.pollAborted) {
|
14324
|
-
this._raiseOnClose();
|
14325
|
-
}
|
14326
|
-
}
|
14327
|
-
}
|
14328
|
-
async send(data) {
|
14329
|
-
if (!this._running) {
|
14330
|
-
return Promise.reject(new Error("Cannot send until the transport is connected"));
|
14331
|
-
}
|
14332
|
-
return sendMessage(this._logger, "LongPolling", this._httpClient, this._url, this._accessTokenFactory, data, this._options);
|
14333
|
-
}
|
14334
|
-
async stop() {
|
14335
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Stopping polling.");
|
14336
|
-
// Tell receiving loop to stop, abort any current request, and then wait for it to finish
|
14337
|
-
this._running = false;
|
14338
|
-
this._pollAbort.abort();
|
14339
|
-
try {
|
14340
|
-
await this._receiving;
|
14341
|
-
// Send DELETE to clean up long polling on the server
|
14342
|
-
this._logger.log(LogLevel.Trace, `(LongPolling transport) sending DELETE request to ${this._url}.`);
|
14343
|
-
const headers = {};
|
14344
|
-
const [name, value] = getUserAgentHeader();
|
14345
|
-
headers[name] = value;
|
14346
|
-
const deleteOptions = {
|
14347
|
-
headers: { ...headers, ...this._options.headers },
|
14348
|
-
timeout: this._options.timeout,
|
14349
|
-
withCredentials: this._options.withCredentials,
|
14350
|
-
};
|
14351
|
-
const token = await this._getAccessToken();
|
14352
|
-
this._updateHeaderToken(deleteOptions, token);
|
14353
|
-
await this._httpClient.delete(this._url, deleteOptions);
|
14354
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) DELETE request sent.");
|
14355
|
-
}
|
14356
|
-
finally {
|
14357
|
-
this._logger.log(LogLevel.Trace, "(LongPolling transport) Stop finished.");
|
14358
|
-
// Raise close event here instead of in polling
|
14359
|
-
// It needs to happen after the DELETE request is sent
|
14360
|
-
this._raiseOnClose();
|
14361
|
-
}
|
14362
|
-
}
|
14363
|
-
_raiseOnClose() {
|
14364
|
-
if (this.onclose) {
|
14365
|
-
let logMessage = "(LongPolling transport) Firing onclose event.";
|
14366
|
-
if (this._closeError) {
|
14367
|
-
logMessage += " Error: " + this._closeError;
|
14368
|
-
}
|
14369
|
-
this._logger.log(LogLevel.Trace, logMessage);
|
14370
|
-
this.onclose(this._closeError);
|
14371
|
-
}
|
14372
|
-
}
|
14373
|
-
}
|
14374
|
-
|
14375
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14376
|
-
/** @private */
|
14377
|
-
class ServerSentEventsTransport {
|
14378
|
-
constructor(httpClient, accessTokenFactory, logger, options) {
|
14379
|
-
this._httpClient = httpClient;
|
14380
|
-
this._accessTokenFactory = accessTokenFactory;
|
14381
|
-
this._logger = logger;
|
14382
|
-
this._options = options;
|
14383
|
-
this.onreceive = null;
|
14384
|
-
this.onclose = null;
|
14385
|
-
}
|
14386
|
-
async connect(url, transferFormat) {
|
14387
|
-
Arg.isRequired(url, "url");
|
14388
|
-
Arg.isRequired(transferFormat, "transferFormat");
|
14389
|
-
Arg.isIn(transferFormat, TransferFormat, "transferFormat");
|
14390
|
-
this._logger.log(LogLevel.Trace, "(SSE transport) Connecting.");
|
14391
|
-
// set url before accessTokenFactory because this.url is only for send and we set the auth header instead of the query string for send
|
14392
|
-
this._url = url;
|
14393
|
-
if (this._accessTokenFactory) {
|
14394
|
-
const token = await this._accessTokenFactory();
|
14395
|
-
if (token) {
|
14396
|
-
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`;
|
14397
|
-
}
|
14398
|
-
}
|
14399
|
-
return new Promise((resolve, reject) => {
|
14400
|
-
let opened = false;
|
14401
|
-
if (transferFormat !== TransferFormat.Text) {
|
14402
|
-
reject(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
|
14403
|
-
return;
|
14404
|
-
}
|
14405
|
-
let eventSource;
|
14406
|
-
if (Platform.isBrowser || Platform.isWebWorker) {
|
14407
|
-
eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials });
|
14408
|
-
}
|
14409
|
-
else {
|
14410
|
-
// Non-browser passes cookies via the dictionary
|
14411
|
-
const cookies = this._httpClient.getCookieString(url);
|
14412
|
-
const headers = {};
|
14413
|
-
headers.Cookie = cookies;
|
14414
|
-
const [name, value] = getUserAgentHeader();
|
14415
|
-
headers[name] = value;
|
14416
|
-
eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials, headers: { ...headers, ...this._options.headers } });
|
14417
|
-
}
|
14418
|
-
try {
|
14419
|
-
eventSource.onmessage = (e) => {
|
14420
|
-
if (this.onreceive) {
|
14421
|
-
try {
|
14422
|
-
this._logger.log(LogLevel.Trace, `(SSE transport) data received. ${getDataDetail(e.data, this._options.logMessageContent)}.`);
|
14423
|
-
this.onreceive(e.data);
|
14424
|
-
}
|
14425
|
-
catch (error) {
|
14426
|
-
this._close(error);
|
14427
|
-
return;
|
14428
|
-
}
|
14429
|
-
}
|
14430
|
-
};
|
14431
|
-
// @ts-ignore: not using event on purpose
|
14432
|
-
eventSource.onerror = (e) => {
|
14433
|
-
// EventSource doesn't give any useful information about server side closes.
|
14434
|
-
if (opened) {
|
14435
|
-
this._close();
|
14436
|
-
}
|
14437
|
-
else {
|
14438
|
-
reject(new Error("EventSource failed to connect. The connection could not be found on the server,"
|
14439
|
-
+ " either the connection ID is not present on the server, or a proxy is refusing/buffering the connection."
|
14440
|
-
+ " If you have multiple servers check that sticky sessions are enabled."));
|
14441
|
-
}
|
14442
|
-
};
|
14443
|
-
eventSource.onopen = () => {
|
14444
|
-
this._logger.log(LogLevel.Information, `SSE connected to ${this._url}`);
|
14445
|
-
this._eventSource = eventSource;
|
14446
|
-
opened = true;
|
14447
|
-
resolve();
|
14448
|
-
};
|
14449
|
-
}
|
14450
|
-
catch (e) {
|
14451
|
-
reject(e);
|
14452
|
-
return;
|
14453
|
-
}
|
14454
|
-
});
|
14455
|
-
}
|
14456
|
-
async send(data) {
|
14457
|
-
if (!this._eventSource) {
|
14458
|
-
return Promise.reject(new Error("Cannot send until the transport is connected"));
|
14459
|
-
}
|
14460
|
-
return sendMessage(this._logger, "SSE", this._httpClient, this._url, this._accessTokenFactory, data, this._options);
|
14461
|
-
}
|
14462
|
-
stop() {
|
14463
|
-
this._close();
|
14464
|
-
return Promise.resolve();
|
14465
|
-
}
|
14466
|
-
_close(e) {
|
14467
|
-
if (this._eventSource) {
|
14468
|
-
this._eventSource.close();
|
14469
|
-
this._eventSource = undefined;
|
14470
|
-
if (this.onclose) {
|
14471
|
-
this.onclose(e);
|
14472
|
-
}
|
14473
|
-
}
|
14474
|
-
}
|
14475
|
-
}
|
14476
|
-
|
14477
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14478
|
-
/** @private */
|
14479
|
-
class WebSocketTransport {
|
14480
|
-
constructor(httpClient, accessTokenFactory, logger, logMessageContent, webSocketConstructor, headers) {
|
14481
|
-
this._logger = logger;
|
14482
|
-
this._accessTokenFactory = accessTokenFactory;
|
14483
|
-
this._logMessageContent = logMessageContent;
|
14484
|
-
this._webSocketConstructor = webSocketConstructor;
|
14485
|
-
this._httpClient = httpClient;
|
14486
|
-
this.onreceive = null;
|
14487
|
-
this.onclose = null;
|
14488
|
-
this._headers = headers;
|
14489
|
-
}
|
14490
|
-
async connect(url, transferFormat) {
|
14491
|
-
Arg.isRequired(url, "url");
|
14492
|
-
Arg.isRequired(transferFormat, "transferFormat");
|
14493
|
-
Arg.isIn(transferFormat, TransferFormat, "transferFormat");
|
14494
|
-
this._logger.log(LogLevel.Trace, "(WebSockets transport) Connecting.");
|
14495
|
-
if (this._accessTokenFactory) {
|
14496
|
-
const token = await this._accessTokenFactory();
|
14497
|
-
if (token) {
|
14498
|
-
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`;
|
14499
|
-
}
|
14500
|
-
}
|
14501
|
-
return new Promise((resolve, reject) => {
|
14502
|
-
url = url.replace(/^http/, "ws");
|
14503
|
-
let webSocket;
|
14504
|
-
const cookies = this._httpClient.getCookieString(url);
|
14505
|
-
let opened = false;
|
14506
|
-
if (Platform.isNode) {
|
14507
|
-
const headers = {};
|
14508
|
-
const [name, value] = getUserAgentHeader();
|
14509
|
-
headers[name] = value;
|
14510
|
-
if (cookies) {
|
14511
|
-
headers[HeaderNames.Cookie] = `${cookies}`;
|
14512
|
-
}
|
14513
|
-
// Only pass headers when in non-browser environments
|
14514
|
-
webSocket = new this._webSocketConstructor(url, undefined, {
|
14515
|
-
headers: { ...headers, ...this._headers },
|
14516
|
-
});
|
14517
|
-
}
|
14518
|
-
if (!webSocket) {
|
14519
|
-
// Chrome is not happy with passing 'undefined' as protocol
|
14520
|
-
webSocket = new this._webSocketConstructor(url);
|
14521
|
-
}
|
14522
|
-
if (transferFormat === TransferFormat.Binary) {
|
14523
|
-
webSocket.binaryType = "arraybuffer";
|
14524
|
-
}
|
14525
|
-
webSocket.onopen = (_event) => {
|
14526
|
-
this._logger.log(LogLevel.Information, `WebSocket connected to ${url}.`);
|
14527
|
-
this._webSocket = webSocket;
|
14528
|
-
opened = true;
|
14529
|
-
resolve();
|
14530
|
-
};
|
14531
|
-
webSocket.onerror = (event) => {
|
14532
|
-
let error = null;
|
14533
|
-
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
14534
|
-
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
14535
|
-
error = event.error;
|
14536
|
-
}
|
14537
|
-
else {
|
14538
|
-
error = "There was an error with the transport";
|
14539
|
-
}
|
14540
|
-
this._logger.log(LogLevel.Information, `(WebSockets transport) ${error}.`);
|
14541
|
-
};
|
14542
|
-
webSocket.onmessage = (message) => {
|
14543
|
-
this._logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this._logMessageContent)}.`);
|
14544
|
-
if (this.onreceive) {
|
14545
|
-
try {
|
14546
|
-
this.onreceive(message.data);
|
14547
|
-
}
|
14548
|
-
catch (error) {
|
14549
|
-
this._close(error);
|
14550
|
-
return;
|
14551
|
-
}
|
14552
|
-
}
|
14553
|
-
};
|
14554
|
-
webSocket.onclose = (event) => {
|
14555
|
-
// Don't call close handler if connection was never established
|
14556
|
-
// We'll reject the connect call instead
|
14557
|
-
if (opened) {
|
14558
|
-
this._close(event);
|
14559
|
-
}
|
14560
|
-
else {
|
14561
|
-
let error = null;
|
14562
|
-
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
14563
|
-
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
14564
|
-
error = event.error;
|
14565
|
-
}
|
14566
|
-
else {
|
14567
|
-
error = "WebSocket failed to connect. The connection could not be found on the server,"
|
14568
|
-
+ " either the endpoint may not be a SignalR endpoint,"
|
14569
|
-
+ " the connection ID is not present on the server, or there is a proxy blocking WebSockets."
|
14570
|
-
+ " If you have multiple servers check that sticky sessions are enabled.";
|
14571
|
-
}
|
14572
|
-
reject(new Error(error));
|
14573
|
-
}
|
14574
|
-
};
|
14575
|
-
});
|
14576
|
-
}
|
14577
|
-
send(data) {
|
14578
|
-
if (this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN) {
|
14579
|
-
this._logger.log(LogLevel.Trace, `(WebSockets transport) sending data. ${getDataDetail(data, this._logMessageContent)}.`);
|
14580
|
-
this._webSocket.send(data);
|
14581
|
-
return Promise.resolve();
|
14582
|
-
}
|
14583
|
-
return Promise.reject("WebSocket is not in the OPEN state");
|
14584
|
-
}
|
14585
|
-
stop() {
|
14586
|
-
if (this._webSocket) {
|
14587
|
-
// Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning
|
14588
|
-
// This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects
|
14589
|
-
this._close(undefined);
|
14590
|
-
}
|
14591
|
-
return Promise.resolve();
|
14592
|
-
}
|
14593
|
-
_close(event) {
|
14594
|
-
// webSocket will be null if the transport did not start successfully
|
14595
|
-
if (this._webSocket) {
|
14596
|
-
// Clear websocket handlers because we are considering the socket closed now
|
14597
|
-
this._webSocket.onclose = () => { };
|
14598
|
-
this._webSocket.onmessage = () => { };
|
14599
|
-
this._webSocket.onerror = () => { };
|
14600
|
-
this._webSocket.close();
|
14601
|
-
this._webSocket = undefined;
|
14602
|
-
}
|
14603
|
-
this._logger.log(LogLevel.Trace, "(WebSockets transport) socket closed.");
|
14604
|
-
if (this.onclose) {
|
14605
|
-
if (this._isCloseEvent(event) && (event.wasClean === false || event.code !== 1000)) {
|
14606
|
-
this.onclose(new Error(`WebSocket closed with status code: ${event.code} (${event.reason || "no reason given"}).`));
|
14607
|
-
}
|
14608
|
-
else if (event instanceof Error) {
|
14609
|
-
this.onclose(event);
|
14610
|
-
}
|
14611
|
-
else {
|
14612
|
-
this.onclose();
|
14613
|
-
}
|
14614
|
-
}
|
14615
|
-
}
|
14616
|
-
_isCloseEvent(event) {
|
14617
|
-
return event && typeof event.wasClean === "boolean" && typeof event.code === "number";
|
14618
|
-
}
|
14619
|
-
}
|
14620
|
-
|
14621
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
14622
|
-
const MAX_REDIRECTS = 100;
|
14623
|
-
/** @private */
|
14624
|
-
class HttpConnection {
|
14625
|
-
constructor(url, options = {}) {
|
14626
|
-
this._stopPromiseResolver = () => { };
|
14627
|
-
this.features = {};
|
14628
|
-
this._negotiateVersion = 1;
|
14629
|
-
Arg.isRequired(url, "url");
|
14630
|
-
this._logger = createLogger(options.logger);
|
14631
|
-
this.baseUrl = this._resolveUrl(url);
|
14632
|
-
options = options || {};
|
14633
|
-
options.logMessageContent = options.logMessageContent === undefined ? false : options.logMessageContent;
|
14634
|
-
if (typeof options.withCredentials === "boolean" || options.withCredentials === undefined) {
|
14635
|
-
options.withCredentials = options.withCredentials === undefined ? true : options.withCredentials;
|
14636
|
-
}
|
14637
|
-
else {
|
14638
|
-
throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");
|
14639
|
-
}
|
14640
|
-
options.timeout = options.timeout === undefined ? 100 * 1000 : options.timeout;
|
14641
|
-
let webSocketModule = null;
|
14642
|
-
let eventSourceModule = null;
|
14643
|
-
if (Platform.isNode && typeof require !== "undefined") {
|
14644
|
-
// In order to ignore the dynamic require in webpack builds we need to do this magic
|
14645
|
-
// @ts-ignore: TS doesn't know about these names
|
14646
|
-
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
14647
|
-
webSocketModule = requireFunc("ws");
|
14648
|
-
eventSourceModule = requireFunc("eventsource");
|
14649
|
-
}
|
14650
|
-
if (!Platform.isNode && typeof WebSocket !== "undefined" && !options.WebSocket) {
|
14651
|
-
options.WebSocket = WebSocket;
|
14652
|
-
}
|
14653
|
-
else if (Platform.isNode && !options.WebSocket) {
|
14654
|
-
if (webSocketModule) {
|
14655
|
-
options.WebSocket = webSocketModule;
|
14656
|
-
}
|
14657
|
-
}
|
14658
|
-
if (!Platform.isNode && typeof EventSource !== "undefined" && !options.EventSource) {
|
14659
|
-
options.EventSource = EventSource;
|
14660
|
-
}
|
14661
|
-
else if (Platform.isNode && !options.EventSource) {
|
14662
|
-
if (typeof eventSourceModule !== "undefined") {
|
14663
|
-
options.EventSource = eventSourceModule;
|
14664
|
-
}
|
14665
|
-
}
|
14666
|
-
this._httpClient = options.httpClient || new DefaultHttpClient(this._logger);
|
14667
|
-
this._connectionState = "Disconnected" /* Disconnected */;
|
14668
|
-
this._connectionStarted = false;
|
14669
|
-
this._options = options;
|
14670
|
-
this.onreceive = null;
|
14671
|
-
this.onclose = null;
|
14672
|
-
}
|
14673
|
-
async start(transferFormat) {
|
14674
|
-
transferFormat = transferFormat || TransferFormat.Binary;
|
14675
|
-
Arg.isIn(transferFormat, TransferFormat, "transferFormat");
|
14676
|
-
this._logger.log(LogLevel.Debug, `Starting connection with transfer format '${TransferFormat[transferFormat]}'.`);
|
14677
|
-
if (this._connectionState !== "Disconnected" /* Disconnected */) {
|
14678
|
-
return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));
|
14679
|
-
}
|
14680
|
-
this._connectionState = "Connecting" /* Connecting */;
|
14681
|
-
this._startInternalPromise = this._startInternal(transferFormat);
|
14682
|
-
await this._startInternalPromise;
|
14683
|
-
// The TypeScript compiler thinks that connectionState must be Connecting here. The TypeScript compiler is wrong.
|
14684
|
-
if (this._connectionState === "Disconnecting" /* Disconnecting */) {
|
14685
|
-
// stop() was called and transitioned the client into the Disconnecting state.
|
14686
|
-
const message = "Failed to start the HttpConnection before stop() was called.";
|
14687
|
-
this._logger.log(LogLevel.Error, message);
|
14688
|
-
// We cannot await stopPromise inside startInternal since stopInternal awaits the startInternalPromise.
|
14689
|
-
await this._stopPromise;
|
14690
|
-
return Promise.reject(new Error(message));
|
14691
|
-
}
|
14692
|
-
else if (this._connectionState !== "Connected" /* Connected */) {
|
14693
|
-
// stop() was called and transitioned the client into the Disconnecting state.
|
14694
|
-
const message = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
|
14695
|
-
this._logger.log(LogLevel.Error, message);
|
14696
|
-
return Promise.reject(new Error(message));
|
14697
|
-
}
|
14698
|
-
this._connectionStarted = true;
|
14699
|
-
}
|
14700
|
-
send(data) {
|
14701
|
-
if (this._connectionState !== "Connected" /* Connected */) {
|
14702
|
-
return Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State."));
|
14703
|
-
}
|
14704
|
-
if (!this._sendQueue) {
|
14705
|
-
this._sendQueue = new TransportSendQueue(this.transport);
|
14706
|
-
}
|
14707
|
-
// Transport will not be null if state is connected
|
14708
|
-
return this._sendQueue.send(data);
|
14709
|
-
}
|
14710
|
-
async stop(error) {
|
14711
|
-
if (this._connectionState === "Disconnected" /* Disconnected */) {
|
14712
|
-
this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnected state.`);
|
14713
|
-
return Promise.resolve();
|
14714
|
-
}
|
14715
|
-
if (this._connectionState === "Disconnecting" /* Disconnecting */) {
|
14716
|
-
this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
|
14717
|
-
return this._stopPromise;
|
14718
|
-
}
|
14719
|
-
this._connectionState = "Disconnecting" /* Disconnecting */;
|
14720
|
-
this._stopPromise = new Promise((resolve) => {
|
14721
|
-
// Don't complete stop() until stopConnection() completes.
|
14722
|
-
this._stopPromiseResolver = resolve;
|
14723
|
-
});
|
14724
|
-
// stopInternal should never throw so just observe it.
|
14725
|
-
await this._stopInternal(error);
|
14726
|
-
await this._stopPromise;
|
14727
|
-
}
|
14728
|
-
async _stopInternal(error) {
|
14729
|
-
// Set error as soon as possible otherwise there is a race between
|
14730
|
-
// the transport closing and providing an error and the error from a close message
|
14731
|
-
// We would prefer the close message error.
|
14732
|
-
this._stopError = error;
|
14733
|
-
try {
|
14734
|
-
await this._startInternalPromise;
|
14735
|
-
}
|
14736
|
-
catch (e) {
|
14737
|
-
// This exception is returned to the user as a rejected Promise from the start method.
|
14738
|
-
}
|
14739
|
-
// The transport's onclose will trigger stopConnection which will run our onclose event.
|
14740
|
-
// The transport should always be set if currently connected. If it wasn't set, it's likely because
|
14741
|
-
// stop was called during start() and start() failed.
|
14742
|
-
if (this.transport) {
|
14743
|
-
try {
|
14744
|
-
await this.transport.stop();
|
14745
|
-
}
|
14746
|
-
catch (e) {
|
14747
|
-
this._logger.log(LogLevel.Error, `HttpConnection.transport.stop() threw error '${e}'.`);
|
14748
|
-
this._stopConnection();
|
14749
|
-
}
|
14750
|
-
this.transport = undefined;
|
14751
|
-
}
|
14752
|
-
else {
|
14753
|
-
this._logger.log(LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
|
14754
|
-
}
|
14755
|
-
}
|
14756
|
-
async _startInternal(transferFormat) {
|
14757
|
-
// Store the original base url and the access token factory since they may change
|
14758
|
-
// as part of negotiating
|
14759
|
-
let url = this.baseUrl;
|
14760
|
-
this._accessTokenFactory = this._options.accessTokenFactory;
|
14761
|
-
try {
|
14762
|
-
if (this._options.skipNegotiation) {
|
14763
|
-
if (this._options.transport === HttpTransportType.WebSockets) {
|
14764
|
-
// No need to add a connection ID in this case
|
14765
|
-
this.transport = this._constructTransport(HttpTransportType.WebSockets);
|
14766
|
-
// We should just call connect directly in this case.
|
14767
|
-
// No fallback or negotiate in this case.
|
14768
|
-
await this._startTransport(url, transferFormat);
|
14769
|
-
}
|
14770
|
-
else {
|
14771
|
-
throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");
|
14772
|
-
}
|
14773
|
-
}
|
14774
|
-
else {
|
14775
|
-
let negotiateResponse = null;
|
14776
|
-
let redirects = 0;
|
14777
|
-
do {
|
14778
|
-
negotiateResponse = await this._getNegotiationResponse(url);
|
14779
|
-
// the user tries to stop the connection when it is being started
|
14780
|
-
if (this._connectionState === "Disconnecting" /* Disconnecting */ || this._connectionState === "Disconnected" /* Disconnected */) {
|
14781
|
-
throw new Error("The connection was stopped during negotiation.");
|
14782
|
-
}
|
14783
|
-
if (negotiateResponse.error) {
|
14784
|
-
throw new Error(negotiateResponse.error);
|
14785
|
-
}
|
14786
|
-
if (negotiateResponse.ProtocolVersion) {
|
14787
|
-
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.");
|
14788
|
-
}
|
14789
|
-
if (negotiateResponse.url) {
|
14790
|
-
url = negotiateResponse.url;
|
14791
|
-
}
|
14792
|
-
if (negotiateResponse.accessToken) {
|
14793
|
-
// Replace the current access token factory with one that uses
|
14794
|
-
// the returned access token
|
14795
|
-
const accessToken = negotiateResponse.accessToken;
|
14796
|
-
this._accessTokenFactory = () => accessToken;
|
14797
|
-
}
|
14798
|
-
redirects++;
|
14799
|
-
} while (negotiateResponse.url && redirects < MAX_REDIRECTS);
|
14800
|
-
if (redirects === MAX_REDIRECTS && negotiateResponse.url) {
|
14801
|
-
throw new Error("Negotiate redirection limit exceeded.");
|
14802
|
-
}
|
14803
|
-
await this._createTransport(url, this._options.transport, negotiateResponse, transferFormat);
|
14804
|
-
}
|
14805
|
-
if (this.transport instanceof LongPollingTransport) {
|
14806
|
-
this.features.inherentKeepAlive = true;
|
14807
|
-
}
|
14808
|
-
if (this._connectionState === "Connecting" /* Connecting */) {
|
14809
|
-
// Ensure the connection transitions to the connected state prior to completing this.startInternalPromise.
|
14810
|
-
// start() will handle the case when stop was called and startInternal exits still in the disconnecting state.
|
14811
|
-
this._logger.log(LogLevel.Debug, "The HttpConnection connected successfully.");
|
14812
|
-
this._connectionState = "Connected" /* Connected */;
|
14813
|
-
}
|
14814
|
-
// stop() is waiting on us via this.startInternalPromise so keep this.transport around so it can clean up.
|
14815
|
-
// This is the only case startInternal can exit in neither the connected nor disconnected state because stopConnection()
|
14816
|
-
// will transition to the disconnected state. start() will wait for the transition using the stopPromise.
|
14817
|
-
}
|
14818
|
-
catch (e) {
|
14819
|
-
this._logger.log(LogLevel.Error, "Failed to start the connection: " + e);
|
14820
|
-
this._connectionState = "Disconnected" /* Disconnected */;
|
14821
|
-
this.transport = undefined;
|
14822
|
-
// if start fails, any active calls to stop assume that start will complete the stop promise
|
14823
|
-
this._stopPromiseResolver();
|
14824
|
-
return Promise.reject(e);
|
14825
|
-
}
|
14826
|
-
}
|
14827
|
-
async _getNegotiationResponse(url) {
|
14828
|
-
const headers = {};
|
14829
|
-
if (this._accessTokenFactory) {
|
14830
|
-
const token = await this._accessTokenFactory();
|
14831
|
-
if (token) {
|
14832
|
-
headers[HeaderNames.Authorization] = `Bearer ${token}`;
|
14833
|
-
}
|
14834
|
-
}
|
14835
|
-
const [name, value] = getUserAgentHeader();
|
14836
|
-
headers[name] = value;
|
14837
|
-
const negotiateUrl = this._resolveNegotiateUrl(url);
|
14838
|
-
this._logger.log(LogLevel.Debug, `Sending negotiation request: ${negotiateUrl}.`);
|
14839
|
-
try {
|
14840
|
-
const response = await this._httpClient.post(negotiateUrl, {
|
14841
|
-
content: "",
|
14842
|
-
headers: { ...headers, ...this._options.headers },
|
14843
|
-
timeout: this._options.timeout,
|
14844
|
-
withCredentials: this._options.withCredentials,
|
14845
|
-
});
|
14846
|
-
if (response.statusCode !== 200) {
|
14847
|
-
return Promise.reject(new Error(`Unexpected status code returned from negotiate '${response.statusCode}'`));
|
14848
|
-
}
|
14849
|
-
const negotiateResponse = JSON.parse(response.content);
|
14850
|
-
if (!negotiateResponse.negotiateVersion || negotiateResponse.negotiateVersion < 1) {
|
14851
|
-
// Negotiate version 0 doesn't use connectionToken
|
14852
|
-
// So we set it equal to connectionId so all our logic can use connectionToken without being aware of the negotiate version
|
14853
|
-
negotiateResponse.connectionToken = negotiateResponse.connectionId;
|
14854
|
-
}
|
14855
|
-
return negotiateResponse;
|
14856
|
-
}
|
14857
|
-
catch (e) {
|
14858
|
-
let errorMessage = "Failed to complete negotiation with the server: " + e;
|
14859
|
-
if (e instanceof HttpError) {
|
14860
|
-
if (e.statusCode === 404) {
|
14861
|
-
errorMessage = errorMessage + " Either this is not a SignalR endpoint or there is a proxy blocking the connection.";
|
14862
|
-
}
|
14863
|
-
}
|
14864
|
-
this._logger.log(LogLevel.Error, errorMessage);
|
14865
|
-
return Promise.reject(new FailedToNegotiateWithServerError(errorMessage));
|
14866
|
-
}
|
14867
|
-
}
|
14868
|
-
_createConnectUrl(url, connectionToken) {
|
14869
|
-
if (!connectionToken) {
|
14870
|
-
return url;
|
14871
|
-
}
|
14872
|
-
return url + (url.indexOf("?") === -1 ? "?" : "&") + `id=${connectionToken}`;
|
14873
|
-
}
|
14874
|
-
async _createTransport(url, requestedTransport, negotiateResponse, requestedTransferFormat) {
|
14875
|
-
let connectUrl = this._createConnectUrl(url, negotiateResponse.connectionToken);
|
14876
|
-
if (this._isITransport(requestedTransport)) {
|
14877
|
-
this._logger.log(LogLevel.Debug, "Connection was provided an instance of ITransport, using that directly.");
|
14878
|
-
this.transport = requestedTransport;
|
14879
|
-
await this._startTransport(connectUrl, requestedTransferFormat);
|
14880
|
-
this.connectionId = negotiateResponse.connectionId;
|
14881
|
-
return;
|
14882
|
-
}
|
14883
|
-
const transportExceptions = [];
|
14884
|
-
const transports = negotiateResponse.availableTransports || [];
|
14885
|
-
let negotiate = negotiateResponse;
|
14886
|
-
for (const endpoint of transports) {
|
14887
|
-
const transportOrError = this._resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat);
|
14888
|
-
if (transportOrError instanceof Error) {
|
14889
|
-
// Store the error and continue, we don't want to cause a re-negotiate in these cases
|
14890
|
-
transportExceptions.push(`${endpoint.transport} failed:`);
|
14891
|
-
transportExceptions.push(transportOrError);
|
14892
|
-
}
|
14893
|
-
else if (this._isITransport(transportOrError)) {
|
14894
|
-
this.transport = transportOrError;
|
14895
|
-
if (!negotiate) {
|
14896
|
-
try {
|
14897
|
-
negotiate = await this._getNegotiationResponse(url);
|
14898
|
-
}
|
14899
|
-
catch (ex) {
|
14900
|
-
return Promise.reject(ex);
|
14901
|
-
}
|
14902
|
-
connectUrl = this._createConnectUrl(url, negotiate.connectionToken);
|
14903
|
-
}
|
14904
|
-
try {
|
14905
|
-
await this._startTransport(connectUrl, requestedTransferFormat);
|
14906
|
-
this.connectionId = negotiate.connectionId;
|
14907
|
-
return;
|
14908
|
-
}
|
14909
|
-
catch (ex) {
|
14910
|
-
this._logger.log(LogLevel.Error, `Failed to start the transport '${endpoint.transport}': ${ex}`);
|
14911
|
-
negotiate = undefined;
|
14912
|
-
transportExceptions.push(new FailedToStartTransportError(`${endpoint.transport} failed: ${ex}`, HttpTransportType[endpoint.transport]));
|
14913
|
-
if (this._connectionState !== "Connecting" /* Connecting */) {
|
14914
|
-
const message = "Failed to select transport before stop() was called.";
|
14915
|
-
this._logger.log(LogLevel.Debug, message);
|
14916
|
-
return Promise.reject(new Error(message));
|
14917
|
-
}
|
14918
|
-
}
|
14919
|
-
}
|
14920
|
-
}
|
14921
|
-
if (transportExceptions.length > 0) {
|
14922
|
-
return Promise.reject(new AggregateErrors(`Unable to connect to the server with any of the available transports. ${transportExceptions.join(" ")}`, transportExceptions));
|
14923
|
-
}
|
14924
|
-
return Promise.reject(new Error("None of the transports supported by the client are supported by the server."));
|
14925
|
-
}
|
14926
|
-
_constructTransport(transport) {
|
14927
|
-
switch (transport) {
|
14928
|
-
case HttpTransportType.WebSockets:
|
14929
|
-
if (!this._options.WebSocket) {
|
14930
|
-
throw new Error("'WebSocket' is not supported in your environment.");
|
14931
|
-
}
|
14932
|
-
return new WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});
|
14933
|
-
case HttpTransportType.ServerSentEvents:
|
14934
|
-
if (!this._options.EventSource) {
|
14935
|
-
throw new Error("'EventSource' is not supported in your environment.");
|
14936
|
-
}
|
14937
|
-
return new ServerSentEventsTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options);
|
14938
|
-
case HttpTransportType.LongPolling:
|
14939
|
-
return new LongPollingTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options);
|
14940
|
-
default:
|
14941
|
-
throw new Error(`Unknown transport: ${transport}.`);
|
14942
|
-
}
|
14943
|
-
}
|
14944
|
-
_startTransport(url, transferFormat) {
|
14945
|
-
this.transport.onreceive = this.onreceive;
|
14946
|
-
this.transport.onclose = (e) => this._stopConnection(e);
|
14947
|
-
return this.transport.connect(url, transferFormat);
|
14948
|
-
}
|
14949
|
-
_resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat) {
|
14950
|
-
const transport = HttpTransportType[endpoint.transport];
|
14951
|
-
if (transport === null || transport === undefined) {
|
14952
|
-
this._logger.log(LogLevel.Debug, `Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
|
14953
|
-
return new Error(`Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
|
14954
|
-
}
|
14955
|
-
else {
|
14956
|
-
if (transportMatches(requestedTransport, transport)) {
|
14957
|
-
const transferFormats = endpoint.transferFormats.map((s) => TransferFormat[s]);
|
14958
|
-
if (transferFormats.indexOf(requestedTransferFormat) >= 0) {
|
14959
|
-
if ((transport === HttpTransportType.WebSockets && !this._options.WebSocket) ||
|
14960
|
-
(transport === HttpTransportType.ServerSentEvents && !this._options.EventSource)) {
|
14961
|
-
this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it is not supported in your environment.'`);
|
14962
|
-
return new UnsupportedTransportError(`'${HttpTransportType[transport]}' is not supported in your environment.`, transport);
|
14963
|
-
}
|
14964
|
-
else {
|
14965
|
-
this._logger.log(LogLevel.Debug, `Selecting transport '${HttpTransportType[transport]}'.`);
|
14966
|
-
try {
|
14967
|
-
return this._constructTransport(transport);
|
14968
|
-
}
|
14969
|
-
catch (ex) {
|
14970
|
-
return ex;
|
14971
|
-
}
|
14972
|
-
}
|
14973
|
-
}
|
14974
|
-
else {
|
14975
|
-
this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it does not support the requested transfer format '${TransferFormat[requestedTransferFormat]}'.`);
|
14976
|
-
return new Error(`'${HttpTransportType[transport]}' does not support ${TransferFormat[requestedTransferFormat]}.`);
|
14977
|
-
}
|
14978
|
-
}
|
14979
|
-
else {
|
14980
|
-
this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it was disabled by the client.`);
|
14981
|
-
return new DisabledTransportError(`'${HttpTransportType[transport]}' is disabled by the client.`, transport);
|
14982
|
-
}
|
14983
|
-
}
|
14984
|
-
}
|
14985
|
-
_isITransport(transport) {
|
14986
|
-
return transport && typeof (transport) === "object" && "connect" in transport;
|
14987
|
-
}
|
14988
|
-
_stopConnection(error) {
|
14989
|
-
this._logger.log(LogLevel.Debug, `HttpConnection.stopConnection(${error}) called while in state ${this._connectionState}.`);
|
14990
|
-
this.transport = undefined;
|
14991
|
-
// If we have a stopError, it takes precedence over the error from the transport
|
14992
|
-
error = this._stopError || error;
|
14993
|
-
this._stopError = undefined;
|
14994
|
-
if (this._connectionState === "Disconnected" /* Disconnected */) {
|
14995
|
-
this._logger.log(LogLevel.Debug, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is already in the disconnected state.`);
|
14996
|
-
return;
|
14997
|
-
}
|
14998
|
-
if (this._connectionState === "Connecting" /* Connecting */) {
|
14999
|
-
this._logger.log(LogLevel.Warning, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is still in the connecting state.`);
|
15000
|
-
throw new Error(`HttpConnection.stopConnection(${error}) was called while the connection is still in the connecting state.`);
|
15001
|
-
}
|
15002
|
-
if (this._connectionState === "Disconnecting" /* Disconnecting */) {
|
15003
|
-
// A call to stop() induced this call to stopConnection and needs to be completed.
|
15004
|
-
// Any stop() awaiters will be scheduled to continue after the onclose callback fires.
|
15005
|
-
this._stopPromiseResolver();
|
15006
|
-
}
|
15007
|
-
if (error) {
|
15008
|
-
this._logger.log(LogLevel.Error, `Connection disconnected with error '${error}'.`);
|
15009
|
-
}
|
15010
|
-
else {
|
15011
|
-
this._logger.log(LogLevel.Information, "Connection disconnected.");
|
15012
|
-
}
|
15013
|
-
if (this._sendQueue) {
|
15014
|
-
this._sendQueue.stop().catch((e) => {
|
15015
|
-
this._logger.log(LogLevel.Error, `TransportSendQueue.stop() threw error '${e}'.`);
|
15016
|
-
});
|
15017
|
-
this._sendQueue = undefined;
|
15018
|
-
}
|
15019
|
-
this.connectionId = undefined;
|
15020
|
-
this._connectionState = "Disconnected" /* Disconnected */;
|
15021
|
-
if (this._connectionStarted) {
|
15022
|
-
this._connectionStarted = false;
|
15023
|
-
try {
|
15024
|
-
if (this.onclose) {
|
15025
|
-
this.onclose(error);
|
15026
|
-
}
|
15027
|
-
}
|
15028
|
-
catch (e) {
|
15029
|
-
this._logger.log(LogLevel.Error, `HttpConnection.onclose(${error}) threw error '${e}'.`);
|
15030
|
-
}
|
15031
|
-
}
|
15032
|
-
}
|
15033
|
-
_resolveUrl(url) {
|
15034
|
-
// startsWith is not supported in IE
|
15035
|
-
if (url.lastIndexOf("https://", 0) === 0 || url.lastIndexOf("http://", 0) === 0) {
|
15036
|
-
return url;
|
15037
|
-
}
|
15038
|
-
if (!Platform.isBrowser) {
|
15039
|
-
throw new Error(`Cannot resolve '${url}'.`);
|
15040
|
-
}
|
15041
|
-
// Setting the url to the href propery of an anchor tag handles normalization
|
15042
|
-
// for us. There are 3 main cases.
|
15043
|
-
// 1. Relative path normalization e.g "b" -> "http://localhost:5000/a/b"
|
15044
|
-
// 2. Absolute path normalization e.g "/a/b" -> "http://localhost:5000/a/b"
|
15045
|
-
// 3. Networkpath reference normalization e.g "//localhost:5000/a/b" -> "http://localhost:5000/a/b"
|
15046
|
-
const aTag = window.document.createElement("a");
|
15047
|
-
aTag.href = url;
|
15048
|
-
this._logger.log(LogLevel.Information, `Normalizing '${url}' to '${aTag.href}'.`);
|
15049
|
-
return aTag.href;
|
15050
|
-
}
|
15051
|
-
_resolveNegotiateUrl(url) {
|
15052
|
-
const index = url.indexOf("?");
|
15053
|
-
let negotiateUrl = url.substring(0, index === -1 ? url.length : index);
|
15054
|
-
if (negotiateUrl[negotiateUrl.length - 1] !== "/") {
|
15055
|
-
negotiateUrl += "/";
|
15056
|
-
}
|
15057
|
-
negotiateUrl += "negotiate";
|
15058
|
-
negotiateUrl += index === -1 ? "" : url.substring(index);
|
15059
|
-
if (negotiateUrl.indexOf("negotiateVersion") === -1) {
|
15060
|
-
negotiateUrl += index === -1 ? "?" : "&";
|
15061
|
-
negotiateUrl += "negotiateVersion=" + this._negotiateVersion;
|
15062
|
-
}
|
15063
|
-
return negotiateUrl;
|
15064
|
-
}
|
15065
|
-
}
|
15066
|
-
function transportMatches(requestedTransport, actualTransport) {
|
15067
|
-
return !requestedTransport || ((actualTransport & requestedTransport) !== 0);
|
15068
|
-
}
|
15069
|
-
/** @private */
|
15070
|
-
class TransportSendQueue {
|
15071
|
-
constructor(_transport) {
|
15072
|
-
this._transport = _transport;
|
15073
|
-
this._buffer = [];
|
15074
|
-
this._executing = true;
|
15075
|
-
this._sendBufferedData = new PromiseSource();
|
15076
|
-
this._transportResult = new PromiseSource();
|
15077
|
-
this._sendLoopPromise = this._sendLoop();
|
15078
|
-
}
|
15079
|
-
send(data) {
|
15080
|
-
this._bufferData(data);
|
15081
|
-
if (!this._transportResult) {
|
15082
|
-
this._transportResult = new PromiseSource();
|
15083
|
-
}
|
15084
|
-
return this._transportResult.promise;
|
15085
|
-
}
|
15086
|
-
stop() {
|
15087
|
-
this._executing = false;
|
15088
|
-
this._sendBufferedData.resolve();
|
15089
|
-
return this._sendLoopPromise;
|
15090
|
-
}
|
15091
|
-
_bufferData(data) {
|
15092
|
-
if (this._buffer.length && typeof (this._buffer[0]) !== typeof (data)) {
|
15093
|
-
throw new Error(`Expected data to be of type ${typeof (this._buffer)} but was of type ${typeof (data)}`);
|
15094
|
-
}
|
15095
|
-
this._buffer.push(data);
|
15096
|
-
this._sendBufferedData.resolve();
|
15097
|
-
}
|
15098
|
-
async _sendLoop() {
|
15099
|
-
while (true) {
|
15100
|
-
await this._sendBufferedData.promise;
|
15101
|
-
if (!this._executing) {
|
15102
|
-
if (this._transportResult) {
|
15103
|
-
this._transportResult.reject("Connection stopped.");
|
15104
|
-
}
|
15105
|
-
break;
|
15106
|
-
}
|
15107
|
-
this._sendBufferedData = new PromiseSource();
|
15108
|
-
const transportResult = this._transportResult;
|
15109
|
-
this._transportResult = undefined;
|
15110
|
-
const data = typeof (this._buffer[0]) === "string" ?
|
15111
|
-
this._buffer.join("") :
|
15112
|
-
TransportSendQueue._concatBuffers(this._buffer);
|
15113
|
-
this._buffer.length = 0;
|
15114
|
-
try {
|
15115
|
-
await this._transport.send(data);
|
15116
|
-
transportResult.resolve();
|
15117
|
-
}
|
15118
|
-
catch (error) {
|
15119
|
-
transportResult.reject(error);
|
15120
|
-
}
|
15121
|
-
}
|
15122
|
-
}
|
15123
|
-
static _concatBuffers(arrayBuffers) {
|
15124
|
-
const totalLength = arrayBuffers.map((b) => b.byteLength).reduce((a, b) => a + b);
|
15125
|
-
const result = new Uint8Array(totalLength);
|
15126
|
-
let offset = 0;
|
15127
|
-
for (const item of arrayBuffers) {
|
15128
|
-
result.set(new Uint8Array(item), offset);
|
15129
|
-
offset += item.byteLength;
|
15130
|
-
}
|
15131
|
-
return result.buffer;
|
15132
|
-
}
|
15133
|
-
}
|
15134
|
-
class PromiseSource {
|
15135
|
-
constructor() {
|
15136
|
-
this.promise = new Promise((resolve, reject) => [this._resolver, this._rejecter] = [resolve, reject]);
|
15137
|
-
}
|
15138
|
-
resolve() {
|
15139
|
-
this._resolver();
|
15140
|
-
}
|
15141
|
-
reject(reason) {
|
15142
|
-
this._rejecter(reason);
|
15143
|
-
}
|
15144
|
-
}
|
15145
|
-
|
15146
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
15147
|
-
const JSON_HUB_PROTOCOL_NAME = "json";
|
15148
|
-
/** Implements the JSON Hub Protocol. */
|
15149
|
-
class JsonHubProtocol {
|
15150
|
-
constructor() {
|
15151
|
-
/** @inheritDoc */
|
15152
|
-
this.name = JSON_HUB_PROTOCOL_NAME;
|
15153
|
-
/** @inheritDoc */
|
15154
|
-
this.version = 1;
|
15155
|
-
/** @inheritDoc */
|
15156
|
-
this.transferFormat = TransferFormat.Text;
|
15157
|
-
}
|
15158
|
-
/** Creates an array of {@link @microsoft/signalr.HubMessage} objects from the specified serialized representation.
|
15159
|
-
*
|
15160
|
-
* @param {string} input A string containing the serialized representation.
|
15161
|
-
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
|
15162
|
-
*/
|
15163
|
-
parseMessages(input, logger) {
|
15164
|
-
// The interface does allow "ArrayBuffer" to be passed in, but this implementation does not. So let's throw a useful error.
|
15165
|
-
if (typeof input !== "string") {
|
15166
|
-
throw new Error("Invalid input for JSON hub protocol. Expected a string.");
|
15167
|
-
}
|
15168
|
-
if (!input) {
|
15169
|
-
return [];
|
15170
|
-
}
|
15171
|
-
if (logger === null) {
|
15172
|
-
logger = NullLogger.instance;
|
15173
|
-
}
|
15174
|
-
// Parse the messages
|
15175
|
-
const messages = TextMessageFormat.parse(input);
|
15176
|
-
const hubMessages = [];
|
15177
|
-
for (const message of messages) {
|
15178
|
-
const parsedMessage = JSON.parse(message);
|
15179
|
-
if (typeof parsedMessage.type !== "number") {
|
15180
|
-
throw new Error("Invalid payload.");
|
15181
|
-
}
|
15182
|
-
switch (parsedMessage.type) {
|
15183
|
-
case MessageType.Invocation:
|
15184
|
-
this._isInvocationMessage(parsedMessage);
|
15185
|
-
break;
|
15186
|
-
case MessageType.StreamItem:
|
15187
|
-
this._isStreamItemMessage(parsedMessage);
|
15188
|
-
break;
|
15189
|
-
case MessageType.Completion:
|
15190
|
-
this._isCompletionMessage(parsedMessage);
|
15191
|
-
break;
|
15192
|
-
case MessageType.Ping:
|
15193
|
-
// Single value, no need to validate
|
15194
|
-
break;
|
15195
|
-
case MessageType.Close:
|
15196
|
-
// All optional values, no need to validate
|
15197
|
-
break;
|
15198
|
-
default:
|
15199
|
-
// Future protocol changes can add message types, old clients can ignore them
|
15200
|
-
logger.log(LogLevel.Information, "Unknown message type '" + parsedMessage.type + "' ignored.");
|
15201
|
-
continue;
|
15202
|
-
}
|
15203
|
-
hubMessages.push(parsedMessage);
|
15204
|
-
}
|
15205
|
-
return hubMessages;
|
15206
|
-
}
|
15207
|
-
/** Writes the specified {@link @microsoft/signalr.HubMessage} to a string and returns it.
|
15208
|
-
*
|
15209
|
-
* @param {HubMessage} message The message to write.
|
15210
|
-
* @returns {string} A string containing the serialized representation of the message.
|
15211
|
-
*/
|
15212
|
-
writeMessage(message) {
|
15213
|
-
return TextMessageFormat.write(JSON.stringify(message));
|
15214
|
-
}
|
15215
|
-
_isInvocationMessage(message) {
|
15216
|
-
this._assertNotEmptyString(message.target, "Invalid payload for Invocation message.");
|
15217
|
-
if (message.invocationId !== undefined) {
|
15218
|
-
this._assertNotEmptyString(message.invocationId, "Invalid payload for Invocation message.");
|
15219
|
-
}
|
15220
|
-
}
|
15221
|
-
_isStreamItemMessage(message) {
|
15222
|
-
this._assertNotEmptyString(message.invocationId, "Invalid payload for StreamItem message.");
|
15223
|
-
if (message.item === undefined) {
|
15224
|
-
throw new Error("Invalid payload for StreamItem message.");
|
15225
|
-
}
|
15226
|
-
}
|
15227
|
-
_isCompletionMessage(message) {
|
15228
|
-
if (message.result && message.error) {
|
15229
|
-
throw new Error("Invalid payload for Completion message.");
|
15230
|
-
}
|
15231
|
-
if (!message.result && message.error) {
|
15232
|
-
this._assertNotEmptyString(message.error, "Invalid payload for Completion message.");
|
15233
|
-
}
|
15234
|
-
this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
|
15235
|
-
}
|
15236
|
-
_assertNotEmptyString(value, errorMessage) {
|
15237
|
-
if (typeof value !== "string" || value === "") {
|
15238
|
-
throw new Error(errorMessage);
|
15239
|
-
}
|
15240
|
-
}
|
15241
|
-
}
|
15242
|
-
|
15243
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
15244
|
-
const LogLevelNameMapping = {
|
15245
|
-
trace: LogLevel.Trace,
|
15246
|
-
debug: LogLevel.Debug,
|
15247
|
-
info: LogLevel.Information,
|
15248
|
-
information: LogLevel.Information,
|
15249
|
-
warn: LogLevel.Warning,
|
15250
|
-
warning: LogLevel.Warning,
|
15251
|
-
error: LogLevel.Error,
|
15252
|
-
critical: LogLevel.Critical,
|
15253
|
-
none: LogLevel.None,
|
15254
|
-
};
|
15255
|
-
function parseLogLevel(name) {
|
15256
|
-
// Case-insensitive matching via lower-casing
|
15257
|
-
// Yes, I know case-folding is a complicated problem in Unicode, but we only support
|
15258
|
-
// the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.
|
15259
|
-
const mapping = LogLevelNameMapping[name.toLowerCase()];
|
15260
|
-
if (typeof mapping !== "undefined") {
|
15261
|
-
return mapping;
|
15262
|
-
}
|
15263
|
-
else {
|
15264
|
-
throw new Error(`Unknown log level: ${name}`);
|
15265
|
-
}
|
15266
|
-
}
|
15267
|
-
/** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
|
15268
|
-
class HubConnectionBuilder {
|
15269
|
-
configureLogging(logging) {
|
15270
|
-
Arg.isRequired(logging, "logging");
|
15271
|
-
if (isLogger(logging)) {
|
15272
|
-
this.logger = logging;
|
15273
|
-
}
|
15274
|
-
else if (typeof logging === "string") {
|
15275
|
-
const logLevel = parseLogLevel(logging);
|
15276
|
-
this.logger = new ConsoleLogger(logLevel);
|
15277
|
-
}
|
15278
|
-
else {
|
15279
|
-
this.logger = new ConsoleLogger(logging);
|
15280
|
-
}
|
15281
|
-
return this;
|
15282
|
-
}
|
15283
|
-
withUrl(url, transportTypeOrOptions) {
|
15284
|
-
Arg.isRequired(url, "url");
|
15285
|
-
Arg.isNotEmpty(url, "url");
|
15286
|
-
this.url = url;
|
15287
|
-
// Flow-typing knows where it's at. Since HttpTransportType is a number and IHttpConnectionOptions is guaranteed
|
15288
|
-
// to be an object, we know (as does TypeScript) this comparison is all we need to figure out which overload was called.
|
15289
|
-
if (typeof transportTypeOrOptions === "object") {
|
15290
|
-
this.httpConnectionOptions = { ...this.httpConnectionOptions, ...transportTypeOrOptions };
|
15291
|
-
}
|
15292
|
-
else {
|
15293
|
-
this.httpConnectionOptions = {
|
15294
|
-
...this.httpConnectionOptions,
|
15295
|
-
transport: transportTypeOrOptions,
|
15296
|
-
};
|
15297
|
-
}
|
15298
|
-
return this;
|
15299
|
-
}
|
15300
|
-
/** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
|
15301
|
-
*
|
15302
|
-
* @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
|
15303
|
-
*/
|
15304
|
-
withHubProtocol(protocol) {
|
15305
|
-
Arg.isRequired(protocol, "protocol");
|
15306
|
-
this.protocol = protocol;
|
15307
|
-
return this;
|
15308
|
-
}
|
15309
|
-
withAutomaticReconnect(retryDelaysOrReconnectPolicy) {
|
15310
|
-
if (this.reconnectPolicy) {
|
15311
|
-
throw new Error("A reconnectPolicy has already been set.");
|
15312
|
-
}
|
15313
|
-
if (!retryDelaysOrReconnectPolicy) {
|
15314
|
-
this.reconnectPolicy = new DefaultReconnectPolicy();
|
15315
|
-
}
|
15316
|
-
else if (Array.isArray(retryDelaysOrReconnectPolicy)) {
|
15317
|
-
this.reconnectPolicy = new DefaultReconnectPolicy(retryDelaysOrReconnectPolicy);
|
15318
|
-
}
|
15319
|
-
else {
|
15320
|
-
this.reconnectPolicy = retryDelaysOrReconnectPolicy;
|
15321
|
-
}
|
15322
|
-
return this;
|
15323
|
-
}
|
15324
|
-
/** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
|
15325
|
-
*
|
15326
|
-
* @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
|
15327
|
-
*/
|
15328
|
-
build() {
|
15329
|
-
// If httpConnectionOptions has a logger, use it. Otherwise, override it with the one
|
15330
|
-
// provided to configureLogger
|
15331
|
-
const httpConnectionOptions = this.httpConnectionOptions || {};
|
15332
|
-
// If it's 'null', the user **explicitly** asked for null, don't mess with it.
|
15333
|
-
if (httpConnectionOptions.logger === undefined) {
|
15334
|
-
// If our logger is undefined or null, that's OK, the HttpConnection constructor will handle it.
|
15335
|
-
httpConnectionOptions.logger = this.logger;
|
15336
|
-
}
|
15337
|
-
// Now create the connection
|
15338
|
-
if (!this.url) {
|
15339
|
-
throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
|
15340
|
-
}
|
15341
|
-
const connection = new HttpConnection(this.url, httpConnectionOptions);
|
15342
|
-
return HubConnection.create(connection, this.logger || NullLogger.instance, this.protocol || new JsonHubProtocol(), this.reconnectPolicy);
|
15343
|
-
}
|
15344
|
-
}
|
15345
|
-
function isLogger(logger) {
|
15346
|
-
return logger.log !== undefined;
|
15347
|
-
}
|
15348
|
-
|
15349
|
-
const { state: state$1, onChange, reset: reset$1 } = createStore({
|
15350
|
-
connecting: false,
|
15351
|
-
connected: false
|
15352
|
-
});
|
15353
|
-
const signalRStore = { state: state$1, onChange, reset: reset$1 };
|
15354
|
-
|
15355
|
-
class SignalRService {
|
15356
|
-
constructor() {
|
15357
|
-
console.log("Starting signalR");
|
15358
|
-
//TODO: update courseClassId
|
15359
|
-
var defaultCourseClassId = 1;
|
15360
|
-
var sparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
|
15361
|
-
this.connection = new HubConnectionBuilder()
|
15362
|
-
.withUrl(`${sparkleConfig.apiUrl}hubs/sparkle?url=${window.location.href}${"&courseClassId=" + defaultCourseClassId }`, {
|
15363
|
-
accessTokenFactory: () => this.getToken(),
|
15364
|
-
skipNegotiation: true,
|
15365
|
-
transport: HttpTransportType.WebSockets
|
15366
|
-
})
|
15367
|
-
.configureLogging(LogLevel.Debug)
|
15368
|
-
//.withAutomaticReconnect()
|
15369
|
-
.withAutomaticReconnect({
|
15370
|
-
nextRetryDelayInMilliseconds: retryContext => {
|
15371
|
-
if (retryContext.elapsedMilliseconds < 60000) {
|
15372
|
-
// If we've been reconnecting for less than 60 seconds so far,
|
15373
|
-
// wait between 0 and 10 seconds before the next reconnect attempt.
|
15374
|
-
return Math.random() * 10000;
|
15375
|
-
}
|
15376
|
-
else {
|
15377
|
-
// If we've been reconnecting for more than 60 seconds so far, stop reconnecting.
|
15378
|
-
return null;
|
15379
|
-
}
|
15380
|
-
}
|
15381
|
-
})
|
15382
|
-
.build();
|
15383
|
-
this.connection.on("SendMessage", (user, data) => {
|
15384
|
-
let payload = JSON.parse(data);
|
15385
|
-
console.log("Server said ", user, payload);
|
15386
|
-
});
|
15387
|
-
this.connection.onclose(error => {
|
15388
|
-
});
|
15389
|
-
this.connection.onreconnecting(error => {
|
15390
|
-
console.assert(this.connection.state === HubConnectionState.Reconnecting);
|
15391
|
-
});
|
15392
|
-
this.connection.onreconnected(connectionId => {
|
15393
|
-
console.assert(this.connection.state === HubConnectionState.Connected);
|
15394
|
-
});
|
15395
|
-
}
|
15396
|
-
static getInstance() {
|
15397
|
-
if (!SignalRService.instance) {
|
15398
|
-
SignalRService.instance = new SignalRService();
|
15399
|
-
}
|
15400
|
-
return SignalRService.instance;
|
15401
|
-
}
|
15402
|
-
async start() {
|
15403
|
-
console.log("start");
|
15404
|
-
try {
|
15405
|
-
signalRStore.state.connecting = true;
|
15406
|
-
signalRStore.state.connected = !signalRStore.state.connecting;
|
15407
|
-
await this.connection.start();
|
15408
|
-
console.log(this.connection);
|
15409
|
-
signalRStore.state.connecting = false;
|
15410
|
-
signalRStore.state.connected = !signalRStore.state.connecting;
|
15411
|
-
console.assert(this.connection.state === HubConnectionState.Connected);
|
15412
|
-
console.log("SignalR Connected.");
|
15413
|
-
}
|
15414
|
-
catch (err) {
|
15415
|
-
console.assert(this.connection.state === HubConnectionState.Disconnected);
|
15416
|
-
console.log(err);
|
15417
|
-
}
|
15418
|
-
}
|
15419
|
-
;
|
15420
|
-
async callSignalR(hub, data) {
|
15421
|
-
console.log('signalR invoke', hub, this.connection.connectionState);
|
15422
|
-
if (!this.getToken()) {
|
15423
|
-
console.log("Cannot connect to signalR. Not logged in");
|
15424
|
-
return;
|
15425
|
-
}
|
15426
|
-
this.connection.invoke(hub, JSON.stringify(data));
|
15427
|
-
console.log('After signalR invoke', hub, this.connection.connectionState);
|
15428
|
-
}
|
15429
|
-
getToken() {
|
15430
|
-
var sparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
|
15431
|
-
if (!!sparkleConfig && !!sparkleConfig.auth && !!sparkleConfig.auth.getToken()) {
|
15432
|
-
return sparkle.auth.getToken();
|
15433
|
-
}
|
15434
|
-
return null;
|
15435
|
-
}
|
15436
|
-
}
|
15437
|
-
|
15438
12459
|
class StoreService {
|
15439
12460
|
constructor() { }
|
15440
12461
|
static getInstance() {
|
@@ -16576,7 +13597,7 @@ const SparklePage = class {
|
|
16576
13597
|
};
|
16577
13598
|
SparklePage.style = pageCss;
|
16578
13599
|
|
16579
|
-
const pageFooterCss = "sparkle-page-footer{margin-top:6rem}sparkle-page-footer .last-updated{color:var(--text-color--light);font-weight:normal;margin-left:auto;text-decoration:underline}sparkle-page-footer .page-footer__row{align-items:center;display:flex;font-size:12px;margin-top:2rem}";
|
13600
|
+
const pageFooterCss = "sparkle-page-footer{margin-top:6rem}sparkle-page-footer .last-updated{color:var(--text-color--light);font-weight:normal;margin-left:auto;text-decoration:underline}sparkle-page-footer .page-footer__row{align-items:center;display:flex;font-size:12px;margin-top:2rem}@media (max-width: 768px){sparkle-page-footer{width:100% !important;left:0 !important}}";
|
16580
13601
|
|
16581
13602
|
const SparklePageFooter = class {
|
16582
13603
|
constructor(hostRef) {
|