reorg
This commit is contained in:
parent
d000f77098
commit
40e8e08690
3487 changed files with 39 additions and 21 deletions
85
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/README.md
Normal file
85
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/README.md
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
JavaScript and TypeScript clients for SignalR for ASP.NET Core and Azure SignalR Service
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @microsoft/signalr
|
||||
# or
|
||||
yarn add @microsoft/signalr
|
||||
```
|
||||
|
||||
To try previews of the next version, use the `next` tag on NPM:
|
||||
|
||||
```bash
|
||||
npm install @microsoft/signalr@next
|
||||
# or
|
||||
yarn add @microsoft/signalr@next
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
See the [SignalR Documentation](https://learn.microsoft.com/aspnet/core/signalr) at learn.microsoft.com for documentation on the latest release. [API Reference Documentation](https://learn.microsoft.com/javascript/api/%40aspnet/signalr/?view=signalr-js-latest) is also available on learn.microsoft.com.
|
||||
|
||||
For documentation on using this client with Azure SignalR Service and Azure Functions, see the [SignalR Service serverless developer guide](https://learn.microsoft.com/azure/azure-signalr/signalr-concept-serverless-development-config).
|
||||
|
||||
### Browser
|
||||
|
||||
To use the client in a browser, copy `*.js` files from the `dist/browser` folder to your script folder include on your page using the `<script>` tag.
|
||||
|
||||
### WebWorker
|
||||
|
||||
To use the client in a webworker, copy `*.js` files from the `dist/webworker` folder to your script folder include on your webworker using the `importScripts` function. Note that webworker SignalR hub connection supports only absolute path to a SignalR hub.
|
||||
|
||||
### Node.js
|
||||
|
||||
To use the client in a NodeJS application, install the package to your `node_modules` folder and use `require('@microsoft/signalr')` to load the module. The object returned by `require('@microsoft/signalr')` has the same members as the global `signalR` object (when used in a browser).
|
||||
|
||||
### Example (Browser)
|
||||
|
||||
```javascript
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/chat")
|
||||
.build();
|
||||
|
||||
connection.on("send", data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke("send", "Hello"));
|
||||
```
|
||||
|
||||
### Example (WebWorker)
|
||||
|
||||
```javascript
|
||||
importScripts('signalr.js');
|
||||
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("https://example.com/signalr/chat")
|
||||
.build();
|
||||
|
||||
connection.on("send", data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke("send", "Hello"));
|
||||
|
||||
```
|
||||
|
||||
### Example (NodeJS)
|
||||
|
||||
```javascript
|
||||
const signalR = require("@microsoft/signalr");
|
||||
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/chat")
|
||||
.build();
|
||||
|
||||
connection.on("send", data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke("send", "Hello"));
|
||||
```
|
||||
3556
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.js
vendored
Normal file
3556
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.min.js
vendored
Normal file
2
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.min.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/browser/signalr.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
32
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AbortController.js
vendored
Normal file
32
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AbortController.js
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AbortController = void 0;
|
||||
// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
||||
// We don't actually ever use the API being polyfilled, we always use the polyfill because
|
||||
// it's a very new API right now.
|
||||
// Not exported from index.
|
||||
/** @private */
|
||||
class AbortController {
|
||||
constructor() {
|
||||
this._isAborted = false;
|
||||
this.onabort = null;
|
||||
}
|
||||
abort() {
|
||||
if (!this._isAborted) {
|
||||
this._isAborted = true;
|
||||
if (this.onabort) {
|
||||
this.onabort();
|
||||
}
|
||||
}
|
||||
}
|
||||
get signal() {
|
||||
return this;
|
||||
}
|
||||
get aborted() {
|
||||
return this._isAborted;
|
||||
}
|
||||
}
|
||||
exports.AbortController = AbortController;
|
||||
//# sourceMappingURL=AbortController.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AbortController.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AbortController.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AbortController.js","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,qFAAqF;AACrF,0FAA0F;AAC1F,iCAAiC;AAEjC,2BAA2B;AAC3B,eAAe;AACf,MAAa,eAAe;IAA5B;QACY,eAAU,GAAY,KAAK,CAAC;QAC7B,YAAO,GAAwB,IAAI,CAAC;IAkB/C,CAAC;IAhBU,KAAK;QACR,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,IAAI,CAAC,OAAO,EAAE;gBACd,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;IACL,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ;AApBD,0CAoBC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController\r\n// We don't actually ever use the API being polyfilled, we always use the polyfill because\r\n// it's a very new API right now.\r\n\r\n// Not exported from index.\r\n/** @private */\r\nexport class AbortController implements AbortSignal {\r\n private _isAborted: boolean = false;\r\n public onabort: (() => void) | null = null;\r\n\r\n public abort(): void {\r\n if (!this._isAborted) {\r\n this._isAborted = true;\r\n if (this.onabort) {\r\n this.onabort();\r\n }\r\n }\r\n }\r\n\r\n get signal(): AbortSignal {\r\n return this;\r\n }\r\n\r\n get aborted(): boolean {\r\n return this._isAborted;\r\n }\r\n}\r\n\r\n/** Represents a signal that can be monitored to determine if a request has been aborted. */\r\nexport interface AbortSignal {\r\n /** Indicates if the request has been aborted. */\r\n aborted: boolean;\r\n /** Set this to a handler that will be invoked when the request is aborted. */\r\n onabort: (() => void) | null;\r\n}\r\n"]}
|
||||
50
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AccessTokenHttpClient.js
vendored
Normal file
50
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AccessTokenHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AccessTokenHttpClient = void 0;
|
||||
const HeaderNames_1 = require("./HeaderNames");
|
||||
const HttpClient_1 = require("./HttpClient");
|
||||
/** @private */
|
||||
class AccessTokenHttpClient extends HttpClient_1.HttpClient {
|
||||
constructor(innerClient, accessTokenFactory) {
|
||||
super();
|
||||
this._innerClient = innerClient;
|
||||
this._accessTokenFactory = accessTokenFactory;
|
||||
}
|
||||
async send(request) {
|
||||
let allowRetry = true;
|
||||
if (this._accessTokenFactory && (!this._accessToken || (request.url && request.url.indexOf("/negotiate?") > 0))) {
|
||||
// don't retry if the request is a negotiate or if we just got a potentially new token from the access token factory
|
||||
allowRetry = false;
|
||||
this._accessToken = await this._accessTokenFactory();
|
||||
}
|
||||
this._setAuthorizationHeader(request);
|
||||
const response = await this._innerClient.send(request);
|
||||
if (allowRetry && response.statusCode === 401 && this._accessTokenFactory) {
|
||||
this._accessToken = await this._accessTokenFactory();
|
||||
this._setAuthorizationHeader(request);
|
||||
return await this._innerClient.send(request);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
_setAuthorizationHeader(request) {
|
||||
if (!request.headers) {
|
||||
request.headers = {};
|
||||
}
|
||||
if (this._accessToken) {
|
||||
request.headers[HeaderNames_1.HeaderNames.Authorization] = `Bearer ${this._accessToken}`;
|
||||
}
|
||||
// don't remove the header if there isn't an access token factory, the user manually added the header in this case
|
||||
else if (this._accessTokenFactory) {
|
||||
if (request.headers[HeaderNames_1.HeaderNames.Authorization]) {
|
||||
delete request.headers[HeaderNames_1.HeaderNames.Authorization];
|
||||
}
|
||||
}
|
||||
}
|
||||
getCookieString(url) {
|
||||
return this._innerClient.getCookieString(url);
|
||||
}
|
||||
}
|
||||
exports.AccessTokenHttpClient = AccessTokenHttpClient;
|
||||
//# sourceMappingURL=AccessTokenHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AccessTokenHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/AccessTokenHttpClient.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AccessTokenHttpClient.js","sourceRoot":"","sources":["../../src/AccessTokenHttpClient.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,+CAA4C;AAC5C,6CAAqE;AAErE,eAAe;AACf,MAAa,qBAAsB,SAAQ,uBAAU;IAKjD,YAAY,WAAuB,EAAE,kBAAgE;QACjG,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAoB;QAClC,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,mBAAmB,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC7G,oHAAoH;YACpH,UAAU,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;SACxD;QACD,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEvD,IAAI,UAAU,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE;YACvE,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACrD,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;YACtC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAChD;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,uBAAuB,CAAC,OAAoB;QAChD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAClB,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;SACxB;QACD,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,yBAAW,CAAC,aAAa,CAAC,GAAG,UAAU,IAAI,CAAC,YAAY,EAAE,CAAA;SAC7E;QACD,kHAAkH;aAC7G,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC/B,IAAI,OAAO,CAAC,OAAO,CAAC,yBAAW,CAAC,aAAa,CAAC,EAAE;gBAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,yBAAW,CAAC,aAAa,CAAC,CAAC;aACrD;SACJ;IACL,CAAC;IAEM,eAAe,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;CACJ;AAhDD,sDAgDC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { HeaderNames } from \"./HeaderNames\";\r\nimport { HttpClient, HttpRequest, HttpResponse } from \"./HttpClient\";\r\n\r\n/** @private */\r\nexport class AccessTokenHttpClient extends HttpClient {\r\n private _innerClient: HttpClient;\r\n _accessToken: string | undefined;\r\n _accessTokenFactory: (() => string | Promise<string>) | undefined;\r\n\r\n constructor(innerClient: HttpClient, accessTokenFactory: (() => string | Promise<string>) | undefined) {\r\n super();\r\n\r\n this._innerClient = innerClient;\r\n this._accessTokenFactory = accessTokenFactory;\r\n }\r\n\r\n public async send(request: HttpRequest): Promise<HttpResponse> {\r\n let allowRetry = true;\r\n if (this._accessTokenFactory && (!this._accessToken || (request.url && request.url.indexOf(\"/negotiate?\") > 0))) {\r\n // don't retry if the request is a negotiate or if we just got a potentially new token from the access token factory\r\n allowRetry = false;\r\n this._accessToken = await this._accessTokenFactory();\r\n }\r\n this._setAuthorizationHeader(request);\r\n const response = await this._innerClient.send(request);\r\n\r\n if (allowRetry && response.statusCode === 401 && this._accessTokenFactory) {\r\n this._accessToken = await this._accessTokenFactory();\r\n this._setAuthorizationHeader(request);\r\n return await this._innerClient.send(request);\r\n }\r\n return response;\r\n }\r\n\r\n private _setAuthorizationHeader(request: HttpRequest) {\r\n if (!request.headers) {\r\n request.headers = {};\r\n }\r\n if (this._accessToken) {\r\n request.headers[HeaderNames.Authorization] = `Bearer ${this._accessToken}`\r\n }\r\n // don't remove the header if there isn't an access token factory, the user manually added the header in this case\r\n else if (this._accessTokenFactory) {\r\n if (request.headers[HeaderNames.Authorization]) {\r\n delete request.headers[HeaderNames.Authorization];\r\n }\r\n }\r\n }\r\n\r\n public getCookieString(url: string): string {\r\n return this._innerClient.getCookieString(url);\r\n }\r\n}"]}
|
||||
45
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultHttpClient.js
vendored
Normal file
45
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DefaultHttpClient = void 0;
|
||||
const Errors_1 = require("./Errors");
|
||||
const FetchHttpClient_1 = require("./FetchHttpClient");
|
||||
const HttpClient_1 = require("./HttpClient");
|
||||
const Utils_1 = require("./Utils");
|
||||
const XhrHttpClient_1 = require("./XhrHttpClient");
|
||||
/** Default implementation of {@link @microsoft/signalr.HttpClient}. */
|
||||
class DefaultHttpClient extends HttpClient_1.HttpClient {
|
||||
/** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
|
||||
constructor(logger) {
|
||||
super();
|
||||
if (typeof fetch !== "undefined" || Utils_1.Platform.isNode) {
|
||||
this._httpClient = new FetchHttpClient_1.FetchHttpClient(logger);
|
||||
}
|
||||
else if (typeof XMLHttpRequest !== "undefined") {
|
||||
this._httpClient = new XhrHttpClient_1.XhrHttpClient(logger);
|
||||
}
|
||||
else {
|
||||
throw new Error("No usable HttpClient found.");
|
||||
}
|
||||
}
|
||||
/** @inheritDoc */
|
||||
send(request) {
|
||||
// Check that abort was not signaled before calling send
|
||||
if (request.abortSignal && request.abortSignal.aborted) {
|
||||
return Promise.reject(new Errors_1.AbortError());
|
||||
}
|
||||
if (!request.method) {
|
||||
return Promise.reject(new Error("No method defined."));
|
||||
}
|
||||
if (!request.url) {
|
||||
return Promise.reject(new Error("No url defined."));
|
||||
}
|
||||
return this._httpClient.send(request);
|
||||
}
|
||||
getCookieString(url) {
|
||||
return this._httpClient.getCookieString(url);
|
||||
}
|
||||
}
|
||||
exports.DefaultHttpClient = DefaultHttpClient;
|
||||
//# sourceMappingURL=DefaultHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultHttpClient.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DefaultHttpClient.js","sourceRoot":"","sources":["../../src/DefaultHttpClient.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,qCAAsC;AACtC,uDAAoD;AACpD,6CAAqE;AAErE,mCAAmC;AACnC,mDAAgD;AAEhD,uEAAuE;AACvE,MAAa,iBAAkB,SAAQ,uBAAU;IAG7C,yJAAyJ;IACzJ,YAAmB,MAAe;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,gBAAQ,CAAC,MAAM,EAAE;YACjD,IAAI,CAAC,WAAW,GAAG,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC;SAClD;aAAM,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;YAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,6BAAa,CAAC,MAAM,CAAC,CAAC;SAChD;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAClD;IACL,CAAC;IAED,kBAAkB;IACX,IAAI,CAAC,OAAoB;QAC5B,wDAAwD;QACxD,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE;YACpD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,mBAAU,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACjB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YACd,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACvD;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEM,eAAe,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;CACJ;AApCD,8CAoCC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { AbortError } from \"./Errors\";\r\nimport { FetchHttpClient } from \"./FetchHttpClient\";\r\nimport { HttpClient, HttpRequest, HttpResponse } from \"./HttpClient\";\r\nimport { ILogger } from \"./ILogger\";\r\nimport { Platform } from \"./Utils\";\r\nimport { XhrHttpClient } from \"./XhrHttpClient\";\r\n\r\n/** Default implementation of {@link @microsoft/signalr.HttpClient}. */\r\nexport class DefaultHttpClient extends HttpClient {\r\n private readonly _httpClient: HttpClient;\r\n\r\n /** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */\r\n public constructor(logger: ILogger) {\r\n super();\r\n\r\n if (typeof fetch !== \"undefined\" || Platform.isNode) {\r\n this._httpClient = new FetchHttpClient(logger);\r\n } else if (typeof XMLHttpRequest !== \"undefined\") {\r\n this._httpClient = new XhrHttpClient(logger);\r\n } else {\r\n throw new Error(\"No usable HttpClient found.\");\r\n }\r\n }\r\n\r\n /** @inheritDoc */\r\n public send(request: HttpRequest): Promise<HttpResponse> {\r\n // Check that abort was not signaled before calling send\r\n if (request.abortSignal && request.abortSignal.aborted) {\r\n return Promise.reject(new AbortError());\r\n }\r\n\r\n if (!request.method) {\r\n return Promise.reject(new Error(\"No method defined.\"));\r\n }\r\n if (!request.url) {\r\n return Promise.reject(new Error(\"No url defined.\"));\r\n }\r\n\r\n return this._httpClient.send(request);\r\n }\r\n\r\n public getCookieString(url: string): string {\r\n return this._httpClient.getCookieString(url);\r\n }\r\n}\r\n"]}
|
||||
18
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultReconnectPolicy.js
vendored
Normal file
18
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultReconnectPolicy.js
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DefaultReconnectPolicy = void 0;
|
||||
// 0, 2, 10, 30 second delays before reconnect attempts.
|
||||
const DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];
|
||||
/** @private */
|
||||
class DefaultReconnectPolicy {
|
||||
constructor(retryDelays) {
|
||||
this._retryDelays = retryDelays !== undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;
|
||||
}
|
||||
nextRetryDelayInMilliseconds(retryContext) {
|
||||
return this._retryDelays[retryContext.previousRetryCount];
|
||||
}
|
||||
}
|
||||
exports.DefaultReconnectPolicy = DefaultReconnectPolicy;
|
||||
//# sourceMappingURL=DefaultReconnectPolicy.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultReconnectPolicy.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DefaultReconnectPolicy.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DefaultReconnectPolicy.js","sourceRoot":"","sources":["../../src/DefaultReconnectPolicy.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAIvE,wDAAwD;AACxD,MAAM,oCAAoC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAE3E,eAAe;AACf,MAAa,sBAAsB;IAG/B,YAAY,WAAsB;QAC9B,IAAI,CAAC,YAAY,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,oCAAoC,CAAC;IAClH,CAAC;IAEM,4BAA4B,CAAC,YAA0B;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAC9D,CAAC;CACJ;AAVD,wDAUC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { IRetryPolicy, RetryContext } from \"./IRetryPolicy\";\r\n\r\n// 0, 2, 10, 30 second delays before reconnect attempts.\r\nconst DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];\r\n\r\n/** @private */\r\nexport class DefaultReconnectPolicy implements IRetryPolicy {\r\n private readonly _retryDelays: (number | null)[];\r\n\r\n constructor(retryDelays?: number[]) {\r\n this._retryDelays = retryDelays !== undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;\r\n }\r\n\r\n public nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null {\r\n return this._retryDelays[retryContext.previousRetryCount];\r\n }\r\n}\r\n"]}
|
||||
26
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.browser.js
vendored
Normal file
26
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.browser.js
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEventSource = exports.getWS = exports.configureAbortController = exports.configureFetch = void 0;
|
||||
/** @private */
|
||||
function configureFetch() {
|
||||
return false;
|
||||
}
|
||||
exports.configureFetch = configureFetch;
|
||||
/** @private */
|
||||
function configureAbortController() {
|
||||
return false;
|
||||
}
|
||||
exports.configureAbortController = configureAbortController;
|
||||
/** @private */
|
||||
function getWS() {
|
||||
throw new Error("Trying to import 'ws' in the browser.");
|
||||
}
|
||||
exports.getWS = getWS;
|
||||
/** @private */
|
||||
function getEventSource() {
|
||||
throw new Error("Trying to import 'eventsource' in the browser.");
|
||||
}
|
||||
exports.getEventSource = getEventSource;
|
||||
//# sourceMappingURL=DynamicImports.browser.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.browser.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.browser.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DynamicImports.browser.js","sourceRoot":"","sources":["../../src/DynamicImports.browser.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,eAAe;AACf,SAAgB,cAAc;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAFD,wCAEC;AAED,eAAe;AACf,SAAgB,wBAAwB;IACpC,OAAO,KAAK,CAAC;AACjB,CAAC;AAFD,4DAEC;AAED,eAAe;AACf,SAAgB,KAAK;IACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,CAAC;AAFD,sBAEC;AAED,eAAe;AACf,SAAgB,cAAc;IAC1B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACtE,CAAC;AAFD,wCAEC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n/** @private */\r\nexport function configureFetch(): boolean {\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function configureAbortController(): boolean {\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function getWS(): any {\r\n throw new Error(\"Trying to import 'ws' in the browser.\");\r\n}\r\n\r\n/** @private */\r\nexport function getEventSource(): any {\r\n throw new Error(\"Trying to import 'eventsource' in the browser.\");\r\n}"]}
|
||||
52
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.js
vendored
Normal file
52
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.js
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEventSource = exports.getWS = exports.configureAbortController = exports.configureFetch = void 0;
|
||||
const Utils_1 = require("./Utils");
|
||||
/** @private */
|
||||
function configureFetch(obj) {
|
||||
// Node added a fetch implementation to the global scope starting in v18.
|
||||
// We need to add a cookie jar in node to be able to share cookies with WebSocket
|
||||
if (typeof fetch === "undefined" || Utils_1.Platform.isNode) {
|
||||
// Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._jar = new (require("tough-cookie")).CookieJar();
|
||||
if (typeof fetch === "undefined") {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._fetchType = require("node-fetch");
|
||||
}
|
||||
else {
|
||||
// Use fetch from Node if available
|
||||
obj._fetchType = fetch;
|
||||
}
|
||||
// node-fetch doesn't have a nice API for getting and setting cookies
|
||||
// fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._fetchType = require("fetch-cookie")(obj._fetchType, obj._jar);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.configureFetch = configureFetch;
|
||||
/** @private */
|
||||
function configureAbortController(obj) {
|
||||
if (typeof AbortController === "undefined") {
|
||||
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
|
||||
obj._abortControllerType = require("abort-controller");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.configureAbortController = configureAbortController;
|
||||
/** @private */
|
||||
function getWS() {
|
||||
return require("ws");
|
||||
}
|
||||
exports.getWS = getWS;
|
||||
/** @private */
|
||||
function getEventSource() {
|
||||
return require("eventsource");
|
||||
}
|
||||
exports.getEventSource = getEventSource;
|
||||
//# sourceMappingURL=DynamicImports.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/DynamicImports.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DynamicImports.js","sourceRoot":"","sources":["../../src/DynamicImports.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAIvE,mCAAmC;AAEnC,eAAe;AACf,SAAgB,cAAc,CAAC,GACkB;IAE7C,yEAAyE;IACzE,iFAAiF;IACjF,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,gBAAQ,CAAC,MAAM,EAAE;QACjD,iHAAiH;QACjH,8DAA8D;QAC9D,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAErD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAC9B,8DAA8D;YAC9D,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;SAC1C;aAAM;YACH,mCAAmC;YACnC,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC;SAC1B;QAED,qEAAqE;QACrE,2FAA2F;QAC3F,8DAA8D;QAC9D,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAzBD,wCAyBC;AAED,eAAe;AACf,SAAgB,wBAAwB,CAAC,GAAqF;IAC1H,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;QACxC,gGAAgG;QAChG,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAPD,4DAOC;AAED,eAAe;AACf,SAAgB,KAAK;IACjB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAFD,sBAEC;AAED,eAAe;AACf,SAAgB,cAAc;IAC1B,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// @ts-ignore: This will be removed from built files and is here to make the types available during dev work\r\nimport { CookieJar } from \"@types/tough-cookie\";\r\nimport { Platform } from \"./Utils\";\r\n\r\n/** @private */\r\nexport function configureFetch(obj: { _fetchType?: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\r\n _jar?: CookieJar }): boolean\r\n{\r\n // Node added a fetch implementation to the global scope starting in v18.\r\n // We need to add a cookie jar in node to be able to share cookies with WebSocket\r\n if (typeof fetch === \"undefined\" || Platform.isNode) {\r\n // Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._jar = new (require(\"tough-cookie\")).CookieJar();\r\n\r\n if (typeof fetch === \"undefined\") {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._fetchType = require(\"node-fetch\");\r\n } else {\r\n // Use fetch from Node if available\r\n obj._fetchType = fetch;\r\n }\r\n\r\n // node-fetch doesn't have a nice API for getting and setting cookies\r\n // fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._fetchType = require(\"fetch-cookie\")(obj._fetchType, obj._jar);\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function configureAbortController(obj: { _abortControllerType: { prototype: AbortController, new(): AbortController } }): boolean {\r\n if (typeof AbortController === \"undefined\") {\r\n // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide\r\n obj._abortControllerType = require(\"abort-controller\");\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function getWS(): any {\r\n return require(\"ws\");\r\n}\r\n\r\n/** @private */\r\nexport function getEventSource(): any {\r\n return require(\"eventsource\");\r\n}"]}
|
||||
145
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Errors.js
vendored
Normal file
145
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Errors.js
vendored
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AggregateErrors = exports.FailedToNegotiateWithServerError = exports.FailedToStartTransportError = exports.DisabledTransportError = exports.UnsupportedTransportError = exports.AbortError = exports.TimeoutError = exports.HttpError = void 0;
|
||||
/** Error thrown when an HTTP request fails. */
|
||||
class HttpError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
* @param {number} statusCode The HTTP status code represented by this error.
|
||||
*/
|
||||
constructor(errorMessage, statusCode) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(`${errorMessage}: Status code '${statusCode}'`);
|
||||
this.statusCode = statusCode;
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.HttpError = HttpError;
|
||||
/** Error thrown when a timeout elapses. */
|
||||
class TimeoutError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage = "A timeout occurred.") {
|
||||
const trueProto = new.target.prototype;
|
||||
super(errorMessage);
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.TimeoutError = TimeoutError;
|
||||
/** Error thrown when an action is aborted. */
|
||||
class AbortError extends Error {
|
||||
/** Constructs a new instance of {@link AbortError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage = "An abort occurred.") {
|
||||
const trueProto = new.target.prototype;
|
||||
super(errorMessage);
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.AbortError = AbortError;
|
||||
/** Error thrown when the selected transport is unsupported by the browser. */
|
||||
/** @private */
|
||||
class UnsupportedTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'UnsupportedTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.UnsupportedTransportError = UnsupportedTransportError;
|
||||
/** Error thrown when the selected transport is disabled by the browser. */
|
||||
/** @private */
|
||||
class DisabledTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'DisabledTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.DisabledTransportError = DisabledTransportError;
|
||||
/** Error thrown when the selected transport cannot be started. */
|
||||
/** @private */
|
||||
class FailedToStartTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'FailedToStartTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.FailedToStartTransportError = FailedToStartTransportError;
|
||||
/** Error thrown when the negotiation with the server failed to complete. */
|
||||
/** @private */
|
||||
class FailedToNegotiateWithServerError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
*/
|
||||
constructor(message) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.errorType = 'FailedToNegotiateWithServerError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.FailedToNegotiateWithServerError = FailedToNegotiateWithServerError;
|
||||
/** Error thrown when multiple errors have occurred. */
|
||||
/** @private */
|
||||
class AggregateErrors extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {Error[]} innerErrors The collection of errors this error is aggregating.
|
||||
*/
|
||||
constructor(message, innerErrors) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.innerErrors = innerErrors;
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
exports.AggregateErrors = AggregateErrors;
|
||||
//# sourceMappingURL=Errors.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Errors.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Errors.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
143
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/FetchHttpClient.js
vendored
Normal file
143
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/FetchHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FetchHttpClient = void 0;
|
||||
const Errors_1 = require("./Errors");
|
||||
const HttpClient_1 = require("./HttpClient");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const Utils_1 = require("./Utils");
|
||||
const DynamicImports_1 = require("./DynamicImports");
|
||||
class FetchHttpClient extends HttpClient_1.HttpClient {
|
||||
constructor(logger) {
|
||||
super();
|
||||
this._logger = logger;
|
||||
// This is how you do "reference" arguments
|
||||
const fetchObj = { _fetchType: undefined, _jar: undefined };
|
||||
if ((0, DynamicImports_1.configureFetch)(fetchObj)) {
|
||||
this._fetchType = fetchObj._fetchType;
|
||||
this._jar = fetchObj._jar;
|
||||
}
|
||||
else {
|
||||
this._fetchType = fetch.bind((0, Utils_1.getGlobalThis)());
|
||||
}
|
||||
this._abortControllerType = AbortController;
|
||||
const abortObj = { _abortControllerType: this._abortControllerType };
|
||||
if ((0, DynamicImports_1.configureAbortController)(abortObj)) {
|
||||
this._abortControllerType = abortObj._abortControllerType;
|
||||
}
|
||||
}
|
||||
/** @inheritDoc */
|
||||
async send(request) {
|
||||
// Check that abort was not signaled before calling send
|
||||
if (request.abortSignal && request.abortSignal.aborted) {
|
||||
throw new Errors_1.AbortError();
|
||||
}
|
||||
if (!request.method) {
|
||||
throw new Error("No method defined.");
|
||||
}
|
||||
if (!request.url) {
|
||||
throw new Error("No url defined.");
|
||||
}
|
||||
const abortController = new this._abortControllerType();
|
||||
let error;
|
||||
// Hook our abortSignal into the abort controller
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = () => {
|
||||
abortController.abort();
|
||||
error = new Errors_1.AbortError();
|
||||
};
|
||||
}
|
||||
// If a timeout has been passed in, setup a timeout to call abort
|
||||
// Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
|
||||
let timeoutId = null;
|
||||
if (request.timeout) {
|
||||
const msTimeout = request.timeout;
|
||||
timeoutId = setTimeout(() => {
|
||||
abortController.abort();
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Timeout from HTTP request.`);
|
||||
error = new Errors_1.TimeoutError();
|
||||
}, msTimeout);
|
||||
}
|
||||
if (request.content === "") {
|
||||
request.content = undefined;
|
||||
}
|
||||
if (request.content) {
|
||||
// Explicitly setting the Content-Type header for React Native on Android platform.
|
||||
request.headers = request.headers || {};
|
||||
if ((0, Utils_1.isArrayBuffer)(request.content)) {
|
||||
request.headers["Content-Type"] = "application/octet-stream";
|
||||
}
|
||||
else {
|
||||
request.headers["Content-Type"] = "text/plain;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
let response;
|
||||
try {
|
||||
response = await this._fetchType(request.url, {
|
||||
body: request.content,
|
||||
cache: "no-cache",
|
||||
credentials: request.withCredentials === true ? "include" : "same-origin",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
...request.headers,
|
||||
},
|
||||
method: request.method,
|
||||
mode: "cors",
|
||||
redirect: "follow",
|
||||
signal: abortController.signal,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Error from HTTP request. ${e}.`);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = null;
|
||||
}
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorMessage = await deserializeContent(response, "text");
|
||||
throw new Errors_1.HttpError(errorMessage || response.statusText, response.status);
|
||||
}
|
||||
const content = deserializeContent(response, request.responseType);
|
||||
const payload = await content;
|
||||
return new HttpClient_1.HttpResponse(response.status, response.statusText, payload);
|
||||
}
|
||||
getCookieString(url) {
|
||||
let cookies = "";
|
||||
if (Utils_1.Platform.isNode && this._jar) {
|
||||
// @ts-ignore: unused variable
|
||||
this._jar.getCookies(url, (e, c) => cookies = c.join("; "));
|
||||
}
|
||||
return cookies;
|
||||
}
|
||||
}
|
||||
exports.FetchHttpClient = FetchHttpClient;
|
||||
function deserializeContent(response, responseType) {
|
||||
let content;
|
||||
switch (responseType) {
|
||||
case "arraybuffer":
|
||||
content = response.arrayBuffer();
|
||||
break;
|
||||
case "text":
|
||||
content = response.text();
|
||||
break;
|
||||
case "blob":
|
||||
case "document":
|
||||
case "json":
|
||||
throw new Error(`${responseType} is not supported.`);
|
||||
default:
|
||||
content = response.text();
|
||||
break;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
//# sourceMappingURL=FetchHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/FetchHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/FetchHttpClient.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
55
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HandshakeProtocol.js
vendored
Normal file
55
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HandshakeProtocol.js
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HandshakeProtocol = void 0;
|
||||
const TextMessageFormat_1 = require("./TextMessageFormat");
|
||||
const Utils_1 = require("./Utils");
|
||||
/** @private */
|
||||
class HandshakeProtocol {
|
||||
// Handshake request is always JSON
|
||||
writeHandshakeRequest(handshakeRequest) {
|
||||
return TextMessageFormat_1.TextMessageFormat.write(JSON.stringify(handshakeRequest));
|
||||
}
|
||||
parseHandshakeResponse(data) {
|
||||
let messageData;
|
||||
let remainingData;
|
||||
if ((0, Utils_1.isArrayBuffer)(data)) {
|
||||
// Format is binary but still need to read JSON text from handshake response
|
||||
const binaryData = new Uint8Array(data);
|
||||
const separatorIndex = binaryData.indexOf(TextMessageFormat_1.TextMessageFormat.RecordSeparatorCode);
|
||||
if (separatorIndex === -1) {
|
||||
throw new Error("Message is incomplete.");
|
||||
}
|
||||
// content before separator is handshake response
|
||||
// optional content after is additional messages
|
||||
const responseLength = separatorIndex + 1;
|
||||
messageData = String.fromCharCode.apply(null, Array.prototype.slice.call(binaryData.slice(0, responseLength)));
|
||||
remainingData = (binaryData.byteLength > responseLength) ? binaryData.slice(responseLength).buffer : null;
|
||||
}
|
||||
else {
|
||||
const textData = data;
|
||||
const separatorIndex = textData.indexOf(TextMessageFormat_1.TextMessageFormat.RecordSeparator);
|
||||
if (separatorIndex === -1) {
|
||||
throw new Error("Message is incomplete.");
|
||||
}
|
||||
// content before separator is handshake response
|
||||
// optional content after is additional messages
|
||||
const responseLength = separatorIndex + 1;
|
||||
messageData = textData.substring(0, responseLength);
|
||||
remainingData = (textData.length > responseLength) ? textData.substring(responseLength) : null;
|
||||
}
|
||||
// At this point we should have just the single handshake message
|
||||
const messages = TextMessageFormat_1.TextMessageFormat.parse(messageData);
|
||||
const response = JSON.parse(messages[0]);
|
||||
if (response.type) {
|
||||
throw new Error("Expected a handshake response from the server.");
|
||||
}
|
||||
const responseMessage = response;
|
||||
// multiple messages could have arrived with handshake
|
||||
// return additional data to be parsed as usual, or null if all parsed
|
||||
return [remainingData, responseMessage];
|
||||
}
|
||||
}
|
||||
exports.HandshakeProtocol = HandshakeProtocol;
|
||||
//# sourceMappingURL=HandshakeProtocol.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HandshakeProtocol.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HandshakeProtocol.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"HandshakeProtocol.js","sourceRoot":"","sources":["../../src/HandshakeProtocol.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,2DAAwD;AACxD,mCAAwC;AAcxC,eAAe;AACf,MAAa,iBAAiB;IAC1B,mCAAmC;IAC5B,qBAAqB,CAAC,gBAAyC;QAClE,OAAO,qCAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrE,CAAC;IAEM,sBAAsB,CAAC,IAAS;QACnC,IAAI,WAAmB,CAAC;QACxB,IAAI,aAAkB,CAAC;QAEvB,IAAI,IAAA,qBAAa,EAAC,IAAI,CAAC,EAAE;YACrB,4EAA4E;YAC5E,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,qCAAiB,CAAC,mBAAmB,CAAC,CAAC;YACjF,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;aAC7C;YAED,iDAAiD;YACjD,gDAAgD;YAChD,MAAM,cAAc,GAAG,cAAc,GAAG,CAAC,CAAC;YAC1C,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;YAC/G,aAAa,GAAG,CAAC,UAAU,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;SAC7G;aAAM;YACH,MAAM,QAAQ,GAAW,IAAI,CAAC;YAC9B,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,qCAAiB,CAAC,eAAe,CAAC,CAAC;YAC3E,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;aAC7C;YAED,iDAAiD;YACjD,gDAAgD;YAChD,MAAM,cAAc,GAAG,cAAc,GAAG,CAAC,CAAC;YAC1C,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;YACpD,aAAa,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;SAClG;QAED,iEAAiE;QACjE,MAAM,QAAQ,GAAG,qCAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,QAAQ,CAAC,IAAI,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACrE;QACD,MAAM,eAAe,GAA6B,QAAQ,CAAC;QAE3D,sDAAsD;QACtD,sEAAsE;QACtE,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC5C,CAAC;CACJ;AAjDD,8CAiDC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { TextMessageFormat } from \"./TextMessageFormat\";\r\nimport { isArrayBuffer } from \"./Utils\";\r\n\r\n/** @private */\r\nexport interface HandshakeRequestMessage {\r\n readonly protocol: string;\r\n readonly version: number;\r\n}\r\n\r\n/** @private */\r\nexport interface HandshakeResponseMessage {\r\n readonly error: string;\r\n readonly minorVersion: number;\r\n}\r\n\r\n/** @private */\r\nexport class HandshakeProtocol {\r\n // Handshake request is always JSON\r\n public writeHandshakeRequest(handshakeRequest: HandshakeRequestMessage): string {\r\n return TextMessageFormat.write(JSON.stringify(handshakeRequest));\r\n }\r\n\r\n public parseHandshakeResponse(data: any): [any, HandshakeResponseMessage] {\r\n let messageData: string;\r\n let remainingData: any;\r\n\r\n if (isArrayBuffer(data)) {\r\n // Format is binary but still need to read JSON text from handshake response\r\n const binaryData = new Uint8Array(data);\r\n const separatorIndex = binaryData.indexOf(TextMessageFormat.RecordSeparatorCode);\r\n if (separatorIndex === -1) {\r\n throw new Error(\"Message is incomplete.\");\r\n }\r\n\r\n // content before separator is handshake response\r\n // optional content after is additional messages\r\n const responseLength = separatorIndex + 1;\r\n messageData = String.fromCharCode.apply(null, Array.prototype.slice.call(binaryData.slice(0, responseLength)));\r\n remainingData = (binaryData.byteLength > responseLength) ? binaryData.slice(responseLength).buffer : null;\r\n } else {\r\n const textData: string = data;\r\n const separatorIndex = textData.indexOf(TextMessageFormat.RecordSeparator);\r\n if (separatorIndex === -1) {\r\n throw new Error(\"Message is incomplete.\");\r\n }\r\n\r\n // content before separator is handshake response\r\n // optional content after is additional messages\r\n const responseLength = separatorIndex + 1;\r\n messageData = textData.substring(0, responseLength);\r\n remainingData = (textData.length > responseLength) ? textData.substring(responseLength) : null;\r\n }\r\n\r\n // At this point we should have just the single handshake message\r\n const messages = TextMessageFormat.parse(messageData);\r\n const response = JSON.parse(messages[0]);\r\n if (response.type) {\r\n throw new Error(\"Expected a handshake response from the server.\");\r\n }\r\n const responseMessage: HandshakeResponseMessage = response;\r\n\r\n // multiple messages could have arrived with handshake\r\n // return additional data to be parsed as usual, or null if all parsed\r\n return [remainingData, responseMessage];\r\n }\r\n}\r\n"]}
|
||||
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HeaderNames.js
vendored
Normal file
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HeaderNames.js
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HeaderNames = void 0;
|
||||
class HeaderNames {
|
||||
}
|
||||
exports.HeaderNames = HeaderNames;
|
||||
HeaderNames.Authorization = "Authorization";
|
||||
HeaderNames.Cookie = "Cookie";
|
||||
//# sourceMappingURL=HeaderNames.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HeaderNames.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HeaderNames.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"HeaderNames.js","sourceRoot":"","sources":["../../src/HeaderNames.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,MAAsB,WAAW;;AAAjC,kCAGC;AAFmB,yBAAa,GAAG,eAAe,CAAC;AAChC,kBAAM,GAAG,QAAQ,CAAC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nexport abstract class HeaderNames {\r\n static readonly Authorization = \"Authorization\";\r\n static readonly Cookie = \"Cookie\";\r\n}\r\n"]}
|
||||
52
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpClient.js
vendored
Normal file
52
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HttpClient = exports.HttpResponse = void 0;
|
||||
/** Represents an HTTP response. */
|
||||
class HttpResponse {
|
||||
constructor(statusCode, statusText, content) {
|
||||
this.statusCode = statusCode;
|
||||
this.statusText = statusText;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
exports.HttpResponse = HttpResponse;
|
||||
/** Abstraction over an HTTP client.
|
||||
*
|
||||
* This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
|
||||
*/
|
||||
class HttpClient {
|
||||
get(url, options) {
|
||||
return this.send({
|
||||
...options,
|
||||
method: "GET",
|
||||
url,
|
||||
});
|
||||
}
|
||||
post(url, options) {
|
||||
return this.send({
|
||||
...options,
|
||||
method: "POST",
|
||||
url,
|
||||
});
|
||||
}
|
||||
delete(url, options) {
|
||||
return this.send({
|
||||
...options,
|
||||
method: "DELETE",
|
||||
url,
|
||||
});
|
||||
}
|
||||
/** Gets all cookies that apply to the specified URL.
|
||||
*
|
||||
* @param url The URL that the cookies are valid for.
|
||||
* @returns {string} A string containing all the key-value cookie pairs for the specified URL.
|
||||
*/
|
||||
// @ts-ignore
|
||||
getCookieString(url) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
exports.HttpClient = HttpClient;
|
||||
//# sourceMappingURL=HttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpClient.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
573
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpConnection.js
vendored
Normal file
573
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpConnection.js
vendored
Normal file
|
|
@ -0,0 +1,573 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TransportSendQueue = exports.HttpConnection = void 0;
|
||||
const AccessTokenHttpClient_1 = require("./AccessTokenHttpClient");
|
||||
const DefaultHttpClient_1 = require("./DefaultHttpClient");
|
||||
const DynamicImports_1 = require("./DynamicImports");
|
||||
const Errors_1 = require("./Errors");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const ITransport_1 = require("./ITransport");
|
||||
const LongPollingTransport_1 = require("./LongPollingTransport");
|
||||
const ServerSentEventsTransport_1 = require("./ServerSentEventsTransport");
|
||||
const Utils_1 = require("./Utils");
|
||||
const WebSocketTransport_1 = require("./WebSocketTransport");
|
||||
const MAX_REDIRECTS = 100;
|
||||
/** @private */
|
||||
class HttpConnection {
|
||||
constructor(url, options = {}) {
|
||||
this._stopPromiseResolver = () => { };
|
||||
this.features = {};
|
||||
this._negotiateVersion = 1;
|
||||
Utils_1.Arg.isRequired(url, "url");
|
||||
this._logger = (0, Utils_1.createLogger)(options.logger);
|
||||
this.baseUrl = this._resolveUrl(url);
|
||||
options = options || {};
|
||||
options.logMessageContent = options.logMessageContent === undefined ? false : options.logMessageContent;
|
||||
if (typeof options.withCredentials === "boolean" || options.withCredentials === undefined) {
|
||||
options.withCredentials = options.withCredentials === undefined ? true : options.withCredentials;
|
||||
}
|
||||
else {
|
||||
throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");
|
||||
}
|
||||
options.timeout = options.timeout === undefined ? 100 * 1000 : options.timeout;
|
||||
let webSocketModule = null;
|
||||
let eventSourceModule = null;
|
||||
if (Utils_1.Platform.isNode && typeof require !== "undefined") {
|
||||
webSocketModule = (0, DynamicImports_1.getWS)();
|
||||
eventSourceModule = (0, DynamicImports_1.getEventSource)();
|
||||
}
|
||||
if (!Utils_1.Platform.isNode && typeof WebSocket !== "undefined" && !options.WebSocket) {
|
||||
options.WebSocket = WebSocket;
|
||||
}
|
||||
else if (Utils_1.Platform.isNode && !options.WebSocket) {
|
||||
if (webSocketModule) {
|
||||
options.WebSocket = webSocketModule;
|
||||
}
|
||||
}
|
||||
if (!Utils_1.Platform.isNode && typeof EventSource !== "undefined" && !options.EventSource) {
|
||||
options.EventSource = EventSource;
|
||||
}
|
||||
else if (Utils_1.Platform.isNode && !options.EventSource) {
|
||||
if (typeof eventSourceModule !== "undefined") {
|
||||
options.EventSource = eventSourceModule;
|
||||
}
|
||||
}
|
||||
this._httpClient = new AccessTokenHttpClient_1.AccessTokenHttpClient(options.httpClient || new DefaultHttpClient_1.DefaultHttpClient(this._logger), options.accessTokenFactory);
|
||||
this._connectionState = "Disconnected" /* ConnectionState.Disconnected */;
|
||||
this._connectionStarted = false;
|
||||
this._options = options;
|
||||
this.onreceive = null;
|
||||
this.onclose = null;
|
||||
}
|
||||
async start(transferFormat) {
|
||||
transferFormat = transferFormat || ITransport_1.TransferFormat.Binary;
|
||||
Utils_1.Arg.isIn(transferFormat, ITransport_1.TransferFormat, "transferFormat");
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Starting connection with transfer format '${ITransport_1.TransferFormat[transferFormat]}'.`);
|
||||
if (this._connectionState !== "Disconnected" /* ConnectionState.Disconnected */) {
|
||||
return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));
|
||||
}
|
||||
this._connectionState = "Connecting" /* ConnectionState.Connecting */;
|
||||
this._startInternalPromise = this._startInternal(transferFormat);
|
||||
await this._startInternalPromise;
|
||||
// The TypeScript compiler thinks that connectionState must be Connecting here. The TypeScript compiler is wrong.
|
||||
if (this._connectionState === "Disconnecting" /* ConnectionState.Disconnecting */) {
|
||||
// stop() was called and transitioned the client into the Disconnecting state.
|
||||
const message = "Failed to start the HttpConnection before stop() was called.";
|
||||
this._logger.log(ILogger_1.LogLevel.Error, message);
|
||||
// We cannot await stopPromise inside startInternal since stopInternal awaits the startInternalPromise.
|
||||
await this._stopPromise;
|
||||
return Promise.reject(new Errors_1.AbortError(message));
|
||||
}
|
||||
else if (this._connectionState !== "Connected" /* ConnectionState.Connected */) {
|
||||
// stop() was called and transitioned the client into the Disconnecting state.
|
||||
const message = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
|
||||
this._logger.log(ILogger_1.LogLevel.Error, message);
|
||||
return Promise.reject(new Errors_1.AbortError(message));
|
||||
}
|
||||
this._connectionStarted = true;
|
||||
}
|
||||
send(data) {
|
||||
if (this._connectionState !== "Connected" /* ConnectionState.Connected */) {
|
||||
return Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State."));
|
||||
}
|
||||
if (!this._sendQueue) {
|
||||
this._sendQueue = new TransportSendQueue(this.transport);
|
||||
}
|
||||
// Transport will not be null if state is connected
|
||||
return this._sendQueue.send(data);
|
||||
}
|
||||
async stop(error) {
|
||||
if (this._connectionState === "Disconnected" /* ConnectionState.Disconnected */) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnected state.`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (this._connectionState === "Disconnecting" /* ConnectionState.Disconnecting */) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
|
||||
return this._stopPromise;
|
||||
}
|
||||
this._connectionState = "Disconnecting" /* ConnectionState.Disconnecting */;
|
||||
this._stopPromise = new Promise((resolve) => {
|
||||
// Don't complete stop() until stopConnection() completes.
|
||||
this._stopPromiseResolver = resolve;
|
||||
});
|
||||
// stopInternal should never throw so just observe it.
|
||||
await this._stopInternal(error);
|
||||
await this._stopPromise;
|
||||
}
|
||||
async _stopInternal(error) {
|
||||
// Set error as soon as possible otherwise there is a race between
|
||||
// the transport closing and providing an error and the error from a close message
|
||||
// We would prefer the close message error.
|
||||
this._stopError = error;
|
||||
try {
|
||||
await this._startInternalPromise;
|
||||
}
|
||||
catch (e) {
|
||||
// This exception is returned to the user as a rejected Promise from the start method.
|
||||
}
|
||||
// The transport's onclose will trigger stopConnection which will run our onclose event.
|
||||
// The transport should always be set if currently connected. If it wasn't set, it's likely because
|
||||
// stop was called during start() and start() failed.
|
||||
if (this.transport) {
|
||||
try {
|
||||
await this.transport.stop();
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `HttpConnection.transport.stop() threw error '${e}'.`);
|
||||
this._stopConnection();
|
||||
}
|
||||
this.transport = undefined;
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
|
||||
}
|
||||
}
|
||||
async _startInternal(transferFormat) {
|
||||
// Store the original base url and the access token factory since they may change
|
||||
// as part of negotiating
|
||||
let url = this.baseUrl;
|
||||
this._accessTokenFactory = this._options.accessTokenFactory;
|
||||
this._httpClient._accessTokenFactory = this._accessTokenFactory;
|
||||
try {
|
||||
if (this._options.skipNegotiation) {
|
||||
if (this._options.transport === ITransport_1.HttpTransportType.WebSockets) {
|
||||
// No need to add a connection ID in this case
|
||||
this.transport = this._constructTransport(ITransport_1.HttpTransportType.WebSockets);
|
||||
// We should just call connect directly in this case.
|
||||
// No fallback or negotiate in this case.
|
||||
await this._startTransport(url, transferFormat);
|
||||
}
|
||||
else {
|
||||
throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
let negotiateResponse = null;
|
||||
let redirects = 0;
|
||||
do {
|
||||
negotiateResponse = await this._getNegotiationResponse(url);
|
||||
// the user tries to stop the connection when it is being started
|
||||
if (this._connectionState === "Disconnecting" /* ConnectionState.Disconnecting */ || this._connectionState === "Disconnected" /* ConnectionState.Disconnected */) {
|
||||
throw new Errors_1.AbortError("The connection was stopped during negotiation.");
|
||||
}
|
||||
if (negotiateResponse.error) {
|
||||
throw new Error(negotiateResponse.error);
|
||||
}
|
||||
if (negotiateResponse.ProtocolVersion) {
|
||||
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.");
|
||||
}
|
||||
if (negotiateResponse.url) {
|
||||
url = negotiateResponse.url;
|
||||
}
|
||||
if (negotiateResponse.accessToken) {
|
||||
// Replace the current access token factory with one that uses
|
||||
// the returned access token
|
||||
const accessToken = negotiateResponse.accessToken;
|
||||
this._accessTokenFactory = () => accessToken;
|
||||
// set the factory to undefined so the AccessTokenHttpClient won't retry with the same token, since we know it won't change until a connection restart
|
||||
this._httpClient._accessToken = accessToken;
|
||||
this._httpClient._accessTokenFactory = undefined;
|
||||
}
|
||||
redirects++;
|
||||
} while (negotiateResponse.url && redirects < MAX_REDIRECTS);
|
||||
if (redirects === MAX_REDIRECTS && negotiateResponse.url) {
|
||||
throw new Error("Negotiate redirection limit exceeded.");
|
||||
}
|
||||
await this._createTransport(url, this._options.transport, negotiateResponse, transferFormat);
|
||||
}
|
||||
if (this.transport instanceof LongPollingTransport_1.LongPollingTransport) {
|
||||
this.features.inherentKeepAlive = true;
|
||||
}
|
||||
if (this._connectionState === "Connecting" /* ConnectionState.Connecting */) {
|
||||
// Ensure the connection transitions to the connected state prior to completing this.startInternalPromise.
|
||||
// start() will handle the case when stop was called and startInternal exits still in the disconnecting state.
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "The HttpConnection connected successfully.");
|
||||
this._connectionState = "Connected" /* ConnectionState.Connected */;
|
||||
}
|
||||
// stop() is waiting on us via this.startInternalPromise so keep this.transport around so it can clean up.
|
||||
// This is the only case startInternal can exit in neither the connected nor disconnected state because stopConnection()
|
||||
// will transition to the disconnected state. start() will wait for the transition using the stopPromise.
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, "Failed to start the connection: " + e);
|
||||
this._connectionState = "Disconnected" /* ConnectionState.Disconnected */;
|
||||
this.transport = undefined;
|
||||
// if start fails, any active calls to stop assume that start will complete the stop promise
|
||||
this._stopPromiseResolver();
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
async _getNegotiationResponse(url) {
|
||||
const headers = {};
|
||||
const [name, value] = (0, Utils_1.getUserAgentHeader)();
|
||||
headers[name] = value;
|
||||
const negotiateUrl = this._resolveNegotiateUrl(url);
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Sending negotiation request: ${negotiateUrl}.`);
|
||||
try {
|
||||
const response = await this._httpClient.post(negotiateUrl, {
|
||||
content: "",
|
||||
headers: { ...headers, ...this._options.headers },
|
||||
timeout: this._options.timeout,
|
||||
withCredentials: this._options.withCredentials,
|
||||
});
|
||||
if (response.statusCode !== 200) {
|
||||
return Promise.reject(new Error(`Unexpected status code returned from negotiate '${response.statusCode}'`));
|
||||
}
|
||||
const negotiateResponse = JSON.parse(response.content);
|
||||
if (!negotiateResponse.negotiateVersion || negotiateResponse.negotiateVersion < 1) {
|
||||
// Negotiate version 0 doesn't use connectionToken
|
||||
// So we set it equal to connectionId so all our logic can use connectionToken without being aware of the negotiate version
|
||||
negotiateResponse.connectionToken = negotiateResponse.connectionId;
|
||||
}
|
||||
if (negotiateResponse.useStatefulReconnect && this._options._useStatefulReconnect !== true) {
|
||||
return Promise.reject(new Errors_1.FailedToNegotiateWithServerError("Client didn't negotiate Stateful Reconnect but the server did."));
|
||||
}
|
||||
return negotiateResponse;
|
||||
}
|
||||
catch (e) {
|
||||
let errorMessage = "Failed to complete negotiation with the server: " + e;
|
||||
if (e instanceof Errors_1.HttpError) {
|
||||
if (e.statusCode === 404) {
|
||||
errorMessage = errorMessage + " Either this is not a SignalR endpoint or there is a proxy blocking the connection.";
|
||||
}
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Error, errorMessage);
|
||||
return Promise.reject(new Errors_1.FailedToNegotiateWithServerError(errorMessage));
|
||||
}
|
||||
}
|
||||
_createConnectUrl(url, connectionToken) {
|
||||
if (!connectionToken) {
|
||||
return url;
|
||||
}
|
||||
return url + (url.indexOf("?") === -1 ? "?" : "&") + `id=${connectionToken}`;
|
||||
}
|
||||
async _createTransport(url, requestedTransport, negotiateResponse, requestedTransferFormat) {
|
||||
let connectUrl = this._createConnectUrl(url, negotiateResponse.connectionToken);
|
||||
if (this._isITransport(requestedTransport)) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Connection was provided an instance of ITransport, using that directly.");
|
||||
this.transport = requestedTransport;
|
||||
await this._startTransport(connectUrl, requestedTransferFormat);
|
||||
this.connectionId = negotiateResponse.connectionId;
|
||||
return;
|
||||
}
|
||||
const transportExceptions = [];
|
||||
const transports = negotiateResponse.availableTransports || [];
|
||||
let negotiate = negotiateResponse;
|
||||
for (const endpoint of transports) {
|
||||
const transportOrError = this._resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat, (negotiate === null || negotiate === void 0 ? void 0 : negotiate.useStatefulReconnect) === true);
|
||||
if (transportOrError instanceof Error) {
|
||||
// Store the error and continue, we don't want to cause a re-negotiate in these cases
|
||||
transportExceptions.push(`${endpoint.transport} failed:`);
|
||||
transportExceptions.push(transportOrError);
|
||||
}
|
||||
else if (this._isITransport(transportOrError)) {
|
||||
this.transport = transportOrError;
|
||||
if (!negotiate) {
|
||||
try {
|
||||
negotiate = await this._getNegotiationResponse(url);
|
||||
}
|
||||
catch (ex) {
|
||||
return Promise.reject(ex);
|
||||
}
|
||||
connectUrl = this._createConnectUrl(url, negotiate.connectionToken);
|
||||
}
|
||||
try {
|
||||
await this._startTransport(connectUrl, requestedTransferFormat);
|
||||
this.connectionId = negotiate.connectionId;
|
||||
return;
|
||||
}
|
||||
catch (ex) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Failed to start the transport '${endpoint.transport}': ${ex}`);
|
||||
negotiate = undefined;
|
||||
transportExceptions.push(new Errors_1.FailedToStartTransportError(`${endpoint.transport} failed: ${ex}`, ITransport_1.HttpTransportType[endpoint.transport]));
|
||||
if (this._connectionState !== "Connecting" /* ConnectionState.Connecting */) {
|
||||
const message = "Failed to select transport before stop() was called.";
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, message);
|
||||
return Promise.reject(new Errors_1.AbortError(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transportExceptions.length > 0) {
|
||||
return Promise.reject(new Errors_1.AggregateErrors(`Unable to connect to the server with any of the available transports. ${transportExceptions.join(" ")}`, transportExceptions));
|
||||
}
|
||||
return Promise.reject(new Error("None of the transports supported by the client are supported by the server."));
|
||||
}
|
||||
_constructTransport(transport) {
|
||||
switch (transport) {
|
||||
case ITransport_1.HttpTransportType.WebSockets:
|
||||
if (!this._options.WebSocket) {
|
||||
throw new Error("'WebSocket' is not supported in your environment.");
|
||||
}
|
||||
return new WebSocketTransport_1.WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});
|
||||
case ITransport_1.HttpTransportType.ServerSentEvents:
|
||||
if (!this._options.EventSource) {
|
||||
throw new Error("'EventSource' is not supported in your environment.");
|
||||
}
|
||||
return new ServerSentEventsTransport_1.ServerSentEventsTransport(this._httpClient, this._httpClient._accessToken, this._logger, this._options);
|
||||
case ITransport_1.HttpTransportType.LongPolling:
|
||||
return new LongPollingTransport_1.LongPollingTransport(this._httpClient, this._logger, this._options);
|
||||
default:
|
||||
throw new Error(`Unknown transport: ${transport}.`);
|
||||
}
|
||||
}
|
||||
_startTransport(url, transferFormat) {
|
||||
this.transport.onreceive = this.onreceive;
|
||||
if (this.features.reconnect) {
|
||||
this.transport.onclose = async (e) => {
|
||||
let callStop = false;
|
||||
if (this.features.reconnect) {
|
||||
try {
|
||||
this.features.disconnected();
|
||||
await this.transport.connect(url, transferFormat);
|
||||
await this.features.resend();
|
||||
}
|
||||
catch {
|
||||
callStop = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._stopConnection(e);
|
||||
return;
|
||||
}
|
||||
if (callStop) {
|
||||
this._stopConnection(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.transport.onclose = (e) => this._stopConnection(e);
|
||||
}
|
||||
return this.transport.connect(url, transferFormat);
|
||||
}
|
||||
_resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat, useStatefulReconnect) {
|
||||
const transport = ITransport_1.HttpTransportType[endpoint.transport];
|
||||
if (transport === null || transport === undefined) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
|
||||
return new Error(`Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
|
||||
}
|
||||
else {
|
||||
if (transportMatches(requestedTransport, transport)) {
|
||||
const transferFormats = endpoint.transferFormats.map((s) => ITransport_1.TransferFormat[s]);
|
||||
if (transferFormats.indexOf(requestedTransferFormat) >= 0) {
|
||||
if ((transport === ITransport_1.HttpTransportType.WebSockets && !this._options.WebSocket) ||
|
||||
(transport === ITransport_1.HttpTransportType.ServerSentEvents && !this._options.EventSource)) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Skipping transport '${ITransport_1.HttpTransportType[transport]}' because it is not supported in your environment.'`);
|
||||
return new Errors_1.UnsupportedTransportError(`'${ITransport_1.HttpTransportType[transport]}' is not supported in your environment.`, transport);
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Selecting transport '${ITransport_1.HttpTransportType[transport]}'.`);
|
||||
try {
|
||||
this.features.reconnect = transport === ITransport_1.HttpTransportType.WebSockets ? useStatefulReconnect : undefined;
|
||||
return this._constructTransport(transport);
|
||||
}
|
||||
catch (ex) {
|
||||
return ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Skipping transport '${ITransport_1.HttpTransportType[transport]}' because it does not support the requested transfer format '${ITransport_1.TransferFormat[requestedTransferFormat]}'.`);
|
||||
return new Error(`'${ITransport_1.HttpTransportType[transport]}' does not support ${ITransport_1.TransferFormat[requestedTransferFormat]}.`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Skipping transport '${ITransport_1.HttpTransportType[transport]}' because it was disabled by the client.`);
|
||||
return new Errors_1.DisabledTransportError(`'${ITransport_1.HttpTransportType[transport]}' is disabled by the client.`, transport);
|
||||
}
|
||||
}
|
||||
}
|
||||
_isITransport(transport) {
|
||||
return transport && typeof (transport) === "object" && "connect" in transport;
|
||||
}
|
||||
_stopConnection(error) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `HttpConnection.stopConnection(${error}) called while in state ${this._connectionState}.`);
|
||||
this.transport = undefined;
|
||||
// If we have a stopError, it takes precedence over the error from the transport
|
||||
error = this._stopError || error;
|
||||
this._stopError = undefined;
|
||||
if (this._connectionState === "Disconnected" /* ConnectionState.Disconnected */) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is already in the disconnected state.`);
|
||||
return;
|
||||
}
|
||||
if (this._connectionState === "Connecting" /* ConnectionState.Connecting */) {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is still in the connecting state.`);
|
||||
throw new Error(`HttpConnection.stopConnection(${error}) was called while the connection is still in the connecting state.`);
|
||||
}
|
||||
if (this._connectionState === "Disconnecting" /* ConnectionState.Disconnecting */) {
|
||||
// A call to stop() induced this call to stopConnection and needs to be completed.
|
||||
// Any stop() awaiters will be scheduled to continue after the onclose callback fires.
|
||||
this._stopPromiseResolver();
|
||||
}
|
||||
if (error) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Connection disconnected with error '${error}'.`);
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, "Connection disconnected.");
|
||||
}
|
||||
if (this._sendQueue) {
|
||||
this._sendQueue.stop().catch((e) => {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `TransportSendQueue.stop() threw error '${e}'.`);
|
||||
});
|
||||
this._sendQueue = undefined;
|
||||
}
|
||||
this.connectionId = undefined;
|
||||
this._connectionState = "Disconnected" /* ConnectionState.Disconnected */;
|
||||
if (this._connectionStarted) {
|
||||
this._connectionStarted = false;
|
||||
try {
|
||||
if (this.onclose) {
|
||||
this.onclose(error);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `HttpConnection.onclose(${error}) threw error '${e}'.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
_resolveUrl(url) {
|
||||
// startsWith is not supported in IE
|
||||
if (url.lastIndexOf("https://", 0) === 0 || url.lastIndexOf("http://", 0) === 0) {
|
||||
return url;
|
||||
}
|
||||
if (!Utils_1.Platform.isBrowser) {
|
||||
throw new Error(`Cannot resolve '${url}'.`);
|
||||
}
|
||||
// Setting the url to the href propery of an anchor tag handles normalization
|
||||
// for us. There are 3 main cases.
|
||||
// 1. Relative path normalization e.g "b" -> "http://localhost:5000/a/b"
|
||||
// 2. Absolute path normalization e.g "/a/b" -> "http://localhost:5000/a/b"
|
||||
// 3. Networkpath reference normalization e.g "//localhost:5000/a/b" -> "http://localhost:5000/a/b"
|
||||
const aTag = window.document.createElement("a");
|
||||
aTag.href = url;
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Normalizing '${url}' to '${aTag.href}'.`);
|
||||
return aTag.href;
|
||||
}
|
||||
_resolveNegotiateUrl(url) {
|
||||
const negotiateUrl = new URL(url);
|
||||
if (negotiateUrl.pathname.endsWith('/')) {
|
||||
negotiateUrl.pathname += "negotiate";
|
||||
}
|
||||
else {
|
||||
negotiateUrl.pathname += "/negotiate";
|
||||
}
|
||||
const searchParams = new URLSearchParams(negotiateUrl.searchParams);
|
||||
if (!searchParams.has("negotiateVersion")) {
|
||||
searchParams.append("negotiateVersion", this._negotiateVersion.toString());
|
||||
}
|
||||
if (searchParams.has("useStatefulReconnect")) {
|
||||
if (searchParams.get("useStatefulReconnect") === "true") {
|
||||
this._options._useStatefulReconnect = true;
|
||||
}
|
||||
}
|
||||
else if (this._options._useStatefulReconnect === true) {
|
||||
searchParams.append("useStatefulReconnect", "true");
|
||||
}
|
||||
negotiateUrl.search = searchParams.toString();
|
||||
return negotiateUrl.toString();
|
||||
}
|
||||
}
|
||||
exports.HttpConnection = HttpConnection;
|
||||
function transportMatches(requestedTransport, actualTransport) {
|
||||
return !requestedTransport || ((actualTransport & requestedTransport) !== 0);
|
||||
}
|
||||
/** @private */
|
||||
class TransportSendQueue {
|
||||
constructor(_transport) {
|
||||
this._transport = _transport;
|
||||
this._buffer = [];
|
||||
this._executing = true;
|
||||
this._sendBufferedData = new PromiseSource();
|
||||
this._transportResult = new PromiseSource();
|
||||
this._sendLoopPromise = this._sendLoop();
|
||||
}
|
||||
send(data) {
|
||||
this._bufferData(data);
|
||||
if (!this._transportResult) {
|
||||
this._transportResult = new PromiseSource();
|
||||
}
|
||||
return this._transportResult.promise;
|
||||
}
|
||||
stop() {
|
||||
this._executing = false;
|
||||
this._sendBufferedData.resolve();
|
||||
return this._sendLoopPromise;
|
||||
}
|
||||
_bufferData(data) {
|
||||
if (this._buffer.length && typeof (this._buffer[0]) !== typeof (data)) {
|
||||
throw new Error(`Expected data to be of type ${typeof (this._buffer)} but was of type ${typeof (data)}`);
|
||||
}
|
||||
this._buffer.push(data);
|
||||
this._sendBufferedData.resolve();
|
||||
}
|
||||
async _sendLoop() {
|
||||
while (true) {
|
||||
await this._sendBufferedData.promise;
|
||||
if (!this._executing) {
|
||||
if (this._transportResult) {
|
||||
this._transportResult.reject("Connection stopped.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
this._sendBufferedData = new PromiseSource();
|
||||
const transportResult = this._transportResult;
|
||||
this._transportResult = undefined;
|
||||
const data = typeof (this._buffer[0]) === "string" ?
|
||||
this._buffer.join("") :
|
||||
TransportSendQueue._concatBuffers(this._buffer);
|
||||
this._buffer.length = 0;
|
||||
try {
|
||||
await this._transport.send(data);
|
||||
transportResult.resolve();
|
||||
}
|
||||
catch (error) {
|
||||
transportResult.reject(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
static _concatBuffers(arrayBuffers) {
|
||||
const totalLength = arrayBuffers.map((b) => b.byteLength).reduce((a, b) => a + b);
|
||||
const result = new Uint8Array(totalLength);
|
||||
let offset = 0;
|
||||
for (const item of arrayBuffers) {
|
||||
result.set(new Uint8Array(item), offset);
|
||||
offset += item.byteLength;
|
||||
}
|
||||
return result.buffer;
|
||||
}
|
||||
}
|
||||
exports.TransportSendQueue = TransportSendQueue;
|
||||
class PromiseSource {
|
||||
constructor() {
|
||||
this.promise = new Promise((resolve, reject) => [this._resolver, this._rejecter] = [resolve, reject]);
|
||||
}
|
||||
resolve() {
|
||||
this._resolver();
|
||||
}
|
||||
reject(reason) {
|
||||
this._rejecter(reason);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=HttpConnection.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpConnection.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HttpConnection.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
941
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnection.js
vendored
Normal file
941
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnection.js
vendored
Normal file
|
|
@ -0,0 +1,941 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HubConnection = exports.HubConnectionState = void 0;
|
||||
const HandshakeProtocol_1 = require("./HandshakeProtocol");
|
||||
const Errors_1 = require("./Errors");
|
||||
const IHubProtocol_1 = require("./IHubProtocol");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const Subject_1 = require("./Subject");
|
||||
const Utils_1 = require("./Utils");
|
||||
const MessageBuffer_1 = require("./MessageBuffer");
|
||||
const DEFAULT_TIMEOUT_IN_MS = 30 * 1000;
|
||||
const DEFAULT_PING_INTERVAL_IN_MS = 15 * 1000;
|
||||
const DEFAULT_STATEFUL_RECONNECT_BUFFER_SIZE = 100000;
|
||||
/** Describes the current state of the {@link HubConnection} to the server. */
|
||||
var HubConnectionState;
|
||||
(function (HubConnectionState) {
|
||||
/** The hub connection is disconnected. */
|
||||
HubConnectionState["Disconnected"] = "Disconnected";
|
||||
/** The hub connection is connecting. */
|
||||
HubConnectionState["Connecting"] = "Connecting";
|
||||
/** The hub connection is connected. */
|
||||
HubConnectionState["Connected"] = "Connected";
|
||||
/** The hub connection is disconnecting. */
|
||||
HubConnectionState["Disconnecting"] = "Disconnecting";
|
||||
/** The hub connection is reconnecting. */
|
||||
HubConnectionState["Reconnecting"] = "Reconnecting";
|
||||
})(HubConnectionState = exports.HubConnectionState || (exports.HubConnectionState = {}));
|
||||
/** Represents a connection to a SignalR Hub. */
|
||||
class HubConnection {
|
||||
/** @internal */
|
||||
// Using a public static factory method means we can have a private constructor and an _internal_
|
||||
// create method that can be used by HubConnectionBuilder. An "internal" constructor would just
|
||||
// be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
|
||||
// public parameter-less constructor.
|
||||
static create(connection, logger, protocol, reconnectPolicy, serverTimeoutInMilliseconds, keepAliveIntervalInMilliseconds, statefulReconnectBufferSize) {
|
||||
return new HubConnection(connection, logger, protocol, reconnectPolicy, serverTimeoutInMilliseconds, keepAliveIntervalInMilliseconds, statefulReconnectBufferSize);
|
||||
}
|
||||
constructor(connection, logger, protocol, reconnectPolicy, serverTimeoutInMilliseconds, keepAliveIntervalInMilliseconds, statefulReconnectBufferSize) {
|
||||
this._nextKeepAlive = 0;
|
||||
this._freezeEventListener = () => {
|
||||
this._logger.log(ILogger_1.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://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep");
|
||||
};
|
||||
Utils_1.Arg.isRequired(connection, "connection");
|
||||
Utils_1.Arg.isRequired(logger, "logger");
|
||||
Utils_1.Arg.isRequired(protocol, "protocol");
|
||||
this.serverTimeoutInMilliseconds = serverTimeoutInMilliseconds !== null && serverTimeoutInMilliseconds !== void 0 ? serverTimeoutInMilliseconds : DEFAULT_TIMEOUT_IN_MS;
|
||||
this.keepAliveIntervalInMilliseconds = keepAliveIntervalInMilliseconds !== null && keepAliveIntervalInMilliseconds !== void 0 ? keepAliveIntervalInMilliseconds : DEFAULT_PING_INTERVAL_IN_MS;
|
||||
this._statefulReconnectBufferSize = statefulReconnectBufferSize !== null && statefulReconnectBufferSize !== void 0 ? statefulReconnectBufferSize : DEFAULT_STATEFUL_RECONNECT_BUFFER_SIZE;
|
||||
this._logger = logger;
|
||||
this._protocol = protocol;
|
||||
this.connection = connection;
|
||||
this._reconnectPolicy = reconnectPolicy;
|
||||
this._handshakeProtocol = new HandshakeProtocol_1.HandshakeProtocol();
|
||||
this.connection.onreceive = (data) => this._processIncomingData(data);
|
||||
this.connection.onclose = (error) => this._connectionClosed(error);
|
||||
this._callbacks = {};
|
||||
this._methods = {};
|
||||
this._closedCallbacks = [];
|
||||
this._reconnectingCallbacks = [];
|
||||
this._reconnectedCallbacks = [];
|
||||
this._invocationId = 0;
|
||||
this._receivedHandshakeResponse = false;
|
||||
this._connectionState = HubConnectionState.Disconnected;
|
||||
this._connectionStarted = false;
|
||||
this._cachedPingMessage = this._protocol.writeMessage({ type: IHubProtocol_1.MessageType.Ping });
|
||||
}
|
||||
/** Indicates the state of the {@link HubConnection} to the server. */
|
||||
get state() {
|
||||
return this._connectionState;
|
||||
}
|
||||
/** Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either
|
||||
* in the disconnected state or if the negotiation step was skipped.
|
||||
*/
|
||||
get connectionId() {
|
||||
return this.connection ? (this.connection.connectionId || null) : null;
|
||||
}
|
||||
/** Indicates the url of the {@link HubConnection} to the server. */
|
||||
get baseUrl() {
|
||||
return this.connection.baseUrl || "";
|
||||
}
|
||||
/**
|
||||
* Sets a new url for the HubConnection. Note that the url can only be changed when the connection is in either the Disconnected or
|
||||
* Reconnecting states.
|
||||
* @param {string} url The url to connect to.
|
||||
*/
|
||||
set baseUrl(url) {
|
||||
if (this._connectionState !== HubConnectionState.Disconnected && this._connectionState !== HubConnectionState.Reconnecting) {
|
||||
throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");
|
||||
}
|
||||
if (!url) {
|
||||
throw new Error("The HubConnection url must be a valid url.");
|
||||
}
|
||||
this.connection.baseUrl = url;
|
||||
}
|
||||
/** Starts the connection.
|
||||
*
|
||||
* @returns {Promise<void>} A Promise that resolves when the connection has been successfully established, or rejects with an error.
|
||||
*/
|
||||
start() {
|
||||
this._startPromise = this._startWithStateTransitions();
|
||||
return this._startPromise;
|
||||
}
|
||||
async _startWithStateTransitions() {
|
||||
if (this._connectionState !== HubConnectionState.Disconnected) {
|
||||
return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));
|
||||
}
|
||||
this._connectionState = HubConnectionState.Connecting;
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Starting HubConnection.");
|
||||
try {
|
||||
await this._startInternal();
|
||||
if (Utils_1.Platform.isBrowser) {
|
||||
// Log when the browser freezes the tab so users know why their connection unexpectedly stopped working
|
||||
window.document.addEventListener("freeze", this._freezeEventListener);
|
||||
}
|
||||
this._connectionState = HubConnectionState.Connected;
|
||||
this._connectionStarted = true;
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "HubConnection connected successfully.");
|
||||
}
|
||||
catch (e) {
|
||||
this._connectionState = HubConnectionState.Disconnected;
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `HubConnection failed to start successfully because of error '${e}'.`);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
async _startInternal() {
|
||||
this._stopDuringStartError = undefined;
|
||||
this._receivedHandshakeResponse = false;
|
||||
// Set up the promise before any connection is (re)started otherwise it could race with received messages
|
||||
const handshakePromise = new Promise((resolve, reject) => {
|
||||
this._handshakeResolver = resolve;
|
||||
this._handshakeRejecter = reject;
|
||||
});
|
||||
await this.connection.start(this._protocol.transferFormat);
|
||||
try {
|
||||
let version = this._protocol.version;
|
||||
if (!this.connection.features.reconnect) {
|
||||
// Stateful Reconnect starts with HubProtocol version 2, newer clients connecting to older servers will fail to connect due to
|
||||
// the handshake only supporting version 1, so we will try to send version 1 during the handshake to keep old servers working.
|
||||
version = 1;
|
||||
}
|
||||
const handshakeRequest = {
|
||||
protocol: this._protocol.name,
|
||||
version,
|
||||
};
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Sending handshake request.");
|
||||
await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(handshakeRequest));
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Using HubProtocol '${this._protocol.name}'.`);
|
||||
// defensively cleanup timeout in case we receive a message from the server before we finish start
|
||||
this._cleanupTimeout();
|
||||
this._resetTimeoutPeriod();
|
||||
this._resetKeepAliveInterval();
|
||||
await handshakePromise;
|
||||
// It's important to check the stopDuringStartError instead of just relying on the handshakePromise
|
||||
// being rejected on close, because this continuation can run after both the handshake completed successfully
|
||||
// and the connection was closed.
|
||||
if (this._stopDuringStartError) {
|
||||
// It's important to throw instead of returning a rejected promise, because we don't want to allow any state
|
||||
// transitions to occur between now and the calling code observing the exceptions. Returning a rejected promise
|
||||
// will cause the calling continuation to get scheduled to run later.
|
||||
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
||||
throw this._stopDuringStartError;
|
||||
}
|
||||
const useStatefulReconnect = this.connection.features.reconnect || false;
|
||||
if (useStatefulReconnect) {
|
||||
this._messageBuffer = new MessageBuffer_1.MessageBuffer(this._protocol, this.connection, this._statefulReconnectBufferSize);
|
||||
this.connection.features.disconnected = this._messageBuffer._disconnected.bind(this._messageBuffer);
|
||||
this.connection.features.resend = () => {
|
||||
if (this._messageBuffer) {
|
||||
return this._messageBuffer._resend();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!this.connection.features.inherentKeepAlive) {
|
||||
await this._sendMessage(this._cachedPingMessage);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`);
|
||||
this._cleanupTimeout();
|
||||
this._cleanupPingTimer();
|
||||
// HttpConnection.stop() should not complete until after the onclose callback is invoked.
|
||||
// This will transition the HubConnection to the disconnected state before HttpConnection.stop() completes.
|
||||
await this.connection.stop(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/** Stops the connection.
|
||||
*
|
||||
* @returns {Promise<void>} A Promise that resolves when the connection has been successfully terminated, or rejects with an error.
|
||||
*/
|
||||
async stop() {
|
||||
// Capture the start promise before the connection might be restarted in an onclose callback.
|
||||
const startPromise = this._startPromise;
|
||||
this.connection.features.reconnect = false;
|
||||
this._stopPromise = this._stopInternal();
|
||||
await this._stopPromise;
|
||||
try {
|
||||
// Awaiting undefined continues immediately
|
||||
await startPromise;
|
||||
}
|
||||
catch (e) {
|
||||
// This exception is returned to the user as a rejected Promise from the start method.
|
||||
}
|
||||
}
|
||||
_stopInternal(error) {
|
||||
if (this._connectionState === HubConnectionState.Disconnected) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Call to HubConnection.stop(${error}) ignored because it is already in the disconnected state.`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (this._connectionState === HubConnectionState.Disconnecting) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
|
||||
return this._stopPromise;
|
||||
}
|
||||
const state = this._connectionState;
|
||||
this._connectionState = HubConnectionState.Disconnecting;
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Stopping HubConnection.");
|
||||
if (this._reconnectDelayHandle) {
|
||||
// We're in a reconnect delay which means the underlying connection is currently already stopped.
|
||||
// Just clear the handle to stop the reconnect loop (which no one is waiting on thankfully) and
|
||||
// fire the onclose callbacks.
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Connection stopped during reconnect delay. Done reconnecting.");
|
||||
clearTimeout(this._reconnectDelayHandle);
|
||||
this._reconnectDelayHandle = undefined;
|
||||
this._completeClose();
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (state === HubConnectionState.Connected) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this._sendCloseMessage();
|
||||
}
|
||||
this._cleanupTimeout();
|
||||
this._cleanupPingTimer();
|
||||
this._stopDuringStartError = error || new Errors_1.AbortError("The connection was stopped before the hub handshake could complete.");
|
||||
// HttpConnection.stop() should not complete until after either HttpConnection.start() fails
|
||||
// or the onclose callback is invoked. The onclose callback will transition the HubConnection
|
||||
// to the disconnected state if need be before HttpConnection.stop() completes.
|
||||
return this.connection.stop(error);
|
||||
}
|
||||
async _sendCloseMessage() {
|
||||
try {
|
||||
await this._sendWithProtocol(this._createCloseMessage());
|
||||
}
|
||||
catch {
|
||||
// Ignore, this is a best effort attempt to let the server know the client closed gracefully.
|
||||
}
|
||||
}
|
||||
/** Invokes a streaming hub method on the server using the specified name and arguments.
|
||||
*
|
||||
* @typeparam T The type of the items returned by the server.
|
||||
* @param {string} methodName The name of the server method to invoke.
|
||||
* @param {any[]} args The arguments used to invoke the server method.
|
||||
* @returns {IStreamResult<T>} An object that yields results from the server as they are received.
|
||||
*/
|
||||
stream(methodName, ...args) {
|
||||
const [streams, streamIds] = this._replaceStreamingParams(args);
|
||||
const invocationDescriptor = this._createStreamInvocation(methodName, args, streamIds);
|
||||
// eslint-disable-next-line prefer-const
|
||||
let promiseQueue;
|
||||
const subject = new Subject_1.Subject();
|
||||
subject.cancelCallback = () => {
|
||||
const cancelInvocation = this._createCancelInvocation(invocationDescriptor.invocationId);
|
||||
delete this._callbacks[invocationDescriptor.invocationId];
|
||||
return promiseQueue.then(() => {
|
||||
return this._sendWithProtocol(cancelInvocation);
|
||||
});
|
||||
};
|
||||
this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
|
||||
if (error) {
|
||||
subject.error(error);
|
||||
return;
|
||||
}
|
||||
else if (invocationEvent) {
|
||||
// invocationEvent will not be null when an error is not passed to the callback
|
||||
if (invocationEvent.type === IHubProtocol_1.MessageType.Completion) {
|
||||
if (invocationEvent.error) {
|
||||
subject.error(new Error(invocationEvent.error));
|
||||
}
|
||||
else {
|
||||
subject.complete();
|
||||
}
|
||||
}
|
||||
else {
|
||||
subject.next((invocationEvent.item));
|
||||
}
|
||||
}
|
||||
};
|
||||
promiseQueue = this._sendWithProtocol(invocationDescriptor)
|
||||
.catch((e) => {
|
||||
subject.error(e);
|
||||
delete this._callbacks[invocationDescriptor.invocationId];
|
||||
});
|
||||
this._launchStreams(streams, promiseQueue);
|
||||
return subject;
|
||||
}
|
||||
_sendMessage(message) {
|
||||
this._resetKeepAliveInterval();
|
||||
return this.connection.send(message);
|
||||
}
|
||||
/**
|
||||
* Sends a js object to the server.
|
||||
* @param message The js object to serialize and send.
|
||||
*/
|
||||
_sendWithProtocol(message) {
|
||||
if (this._messageBuffer) {
|
||||
return this._messageBuffer._send(message);
|
||||
}
|
||||
else {
|
||||
return this._sendMessage(this._protocol.writeMessage(message));
|
||||
}
|
||||
}
|
||||
/** Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
|
||||
*
|
||||
* The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still
|
||||
* be processing the invocation.
|
||||
*
|
||||
* @param {string} methodName The name of the server method to invoke.
|
||||
* @param {any[]} args The arguments used to invoke the server method.
|
||||
* @returns {Promise<void>} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
|
||||
*/
|
||||
send(methodName, ...args) {
|
||||
const [streams, streamIds] = this._replaceStreamingParams(args);
|
||||
const sendPromise = this._sendWithProtocol(this._createInvocation(methodName, args, true, streamIds));
|
||||
this._launchStreams(streams, sendPromise);
|
||||
return sendPromise;
|
||||
}
|
||||
/** Invokes a hub method on the server using the specified name and arguments.
|
||||
*
|
||||
* The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise
|
||||
* resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of
|
||||
* resolving the Promise.
|
||||
*
|
||||
* @typeparam T The expected return type.
|
||||
* @param {string} methodName The name of the server method to invoke.
|
||||
* @param {any[]} args The arguments used to invoke the server method.
|
||||
* @returns {Promise<T>} A Promise that resolves with the result of the server method (if any), or rejects with an error.
|
||||
*/
|
||||
invoke(methodName, ...args) {
|
||||
const [streams, streamIds] = this._replaceStreamingParams(args);
|
||||
const invocationDescriptor = this._createInvocation(methodName, args, false, streamIds);
|
||||
const p = new Promise((resolve, reject) => {
|
||||
// invocationId will always have a value for a non-blocking invocation
|
||||
this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
else if (invocationEvent) {
|
||||
// invocationEvent will not be null when an error is not passed to the callback
|
||||
if (invocationEvent.type === IHubProtocol_1.MessageType.Completion) {
|
||||
if (invocationEvent.error) {
|
||||
reject(new Error(invocationEvent.error));
|
||||
}
|
||||
else {
|
||||
resolve(invocationEvent.result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
reject(new Error(`Unexpected message type: ${invocationEvent.type}`));
|
||||
}
|
||||
}
|
||||
};
|
||||
const promiseQueue = this._sendWithProtocol(invocationDescriptor)
|
||||
.catch((e) => {
|
||||
reject(e);
|
||||
// invocationId will always have a value for a non-blocking invocation
|
||||
delete this._callbacks[invocationDescriptor.invocationId];
|
||||
});
|
||||
this._launchStreams(streams, promiseQueue);
|
||||
});
|
||||
return p;
|
||||
}
|
||||
on(methodName, newMethod) {
|
||||
if (!methodName || !newMethod) {
|
||||
return;
|
||||
}
|
||||
methodName = methodName.toLowerCase();
|
||||
if (!this._methods[methodName]) {
|
||||
this._methods[methodName] = [];
|
||||
}
|
||||
// Preventing adding the same handler multiple times.
|
||||
if (this._methods[methodName].indexOf(newMethod) !== -1) {
|
||||
return;
|
||||
}
|
||||
this._methods[methodName].push(newMethod);
|
||||
}
|
||||
off(methodName, method) {
|
||||
if (!methodName) {
|
||||
return;
|
||||
}
|
||||
methodName = methodName.toLowerCase();
|
||||
const handlers = this._methods[methodName];
|
||||
if (!handlers) {
|
||||
return;
|
||||
}
|
||||
if (method) {
|
||||
const removeIdx = handlers.indexOf(method);
|
||||
if (removeIdx !== -1) {
|
||||
handlers.splice(removeIdx, 1);
|
||||
if (handlers.length === 0) {
|
||||
delete this._methods[methodName];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete this._methods[methodName];
|
||||
}
|
||||
}
|
||||
/** Registers a handler that will be invoked when the connection is closed.
|
||||
*
|
||||
* @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).
|
||||
*/
|
||||
onclose(callback) {
|
||||
if (callback) {
|
||||
this._closedCallbacks.push(callback);
|
||||
}
|
||||
}
|
||||
/** Registers a handler that will be invoked when the connection starts reconnecting.
|
||||
*
|
||||
* @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).
|
||||
*/
|
||||
onreconnecting(callback) {
|
||||
if (callback) {
|
||||
this._reconnectingCallbacks.push(callback);
|
||||
}
|
||||
}
|
||||
/** Registers a handler that will be invoked when the connection successfully reconnects.
|
||||
*
|
||||
* @param {Function} callback The handler that will be invoked when the connection successfully reconnects.
|
||||
*/
|
||||
onreconnected(callback) {
|
||||
if (callback) {
|
||||
this._reconnectedCallbacks.push(callback);
|
||||
}
|
||||
}
|
||||
_processIncomingData(data) {
|
||||
this._cleanupTimeout();
|
||||
if (!this._receivedHandshakeResponse) {
|
||||
data = this._processHandshakeResponse(data);
|
||||
this._receivedHandshakeResponse = true;
|
||||
}
|
||||
// Data may have all been read when processing handshake response
|
||||
if (data) {
|
||||
// Parse the messages
|
||||
const messages = this._protocol.parseMessages(data, this._logger);
|
||||
for (const message of messages) {
|
||||
if (this._messageBuffer && !this._messageBuffer._shouldProcessMessage(message)) {
|
||||
// Don't process the message, we are either waiting for a SequenceMessage or received a duplicate message
|
||||
continue;
|
||||
}
|
||||
switch (message.type) {
|
||||
case IHubProtocol_1.MessageType.Invocation:
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this._invokeClientMethod(message);
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.StreamItem:
|
||||
case IHubProtocol_1.MessageType.Completion: {
|
||||
const callback = this._callbacks[message.invocationId];
|
||||
if (callback) {
|
||||
if (message.type === IHubProtocol_1.MessageType.Completion) {
|
||||
delete this._callbacks[message.invocationId];
|
||||
}
|
||||
try {
|
||||
callback(message);
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Stream callback threw error: ${(0, Utils_1.getErrorString)(e)}`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IHubProtocol_1.MessageType.Ping:
|
||||
// Don't care about pings
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Close: {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, "Close message received from server.");
|
||||
const error = message.error ? new Error("Server returned an error on close: " + message.error) : undefined;
|
||||
if (message.allowReconnect === true) {
|
||||
// It feels wrong not to await connection.stop() here, but processIncomingData is called as part of an onreceive callback which is not async,
|
||||
// this is already the behavior for serverTimeout(), and HttpConnection.Stop() should catch and log all possible exceptions.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.connection.stop(error);
|
||||
}
|
||||
else {
|
||||
// We cannot await stopInternal() here, but subsequent calls to stop() will await this if stopInternal() is still ongoing.
|
||||
this._stopPromise = this._stopInternal(error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IHubProtocol_1.MessageType.Ack:
|
||||
if (this._messageBuffer) {
|
||||
this._messageBuffer._ack(message);
|
||||
}
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Sequence:
|
||||
if (this._messageBuffer) {
|
||||
this._messageBuffer._resetSequence(message);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Invalid message type: ${message.type}.`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._resetTimeoutPeriod();
|
||||
}
|
||||
_processHandshakeResponse(data) {
|
||||
let responseMessage;
|
||||
let remainingData;
|
||||
try {
|
||||
[remainingData, responseMessage] = this._handshakeProtocol.parseHandshakeResponse(data);
|
||||
}
|
||||
catch (e) {
|
||||
const message = "Error parsing handshake response: " + e;
|
||||
this._logger.log(ILogger_1.LogLevel.Error, message);
|
||||
const error = new Error(message);
|
||||
this._handshakeRejecter(error);
|
||||
throw error;
|
||||
}
|
||||
if (responseMessage.error) {
|
||||
const message = "Server returned handshake error: " + responseMessage.error;
|
||||
this._logger.log(ILogger_1.LogLevel.Error, message);
|
||||
const error = new Error(message);
|
||||
this._handshakeRejecter(error);
|
||||
throw error;
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Server handshake complete.");
|
||||
}
|
||||
this._handshakeResolver();
|
||||
return remainingData;
|
||||
}
|
||||
_resetKeepAliveInterval() {
|
||||
if (this.connection.features.inherentKeepAlive) {
|
||||
return;
|
||||
}
|
||||
// Set the time we want the next keep alive to be sent
|
||||
// Timer will be setup on next message receive
|
||||
this._nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds;
|
||||
this._cleanupPingTimer();
|
||||
}
|
||||
_resetTimeoutPeriod() {
|
||||
if (!this.connection.features || !this.connection.features.inherentKeepAlive) {
|
||||
// Set the timeout timer
|
||||
this._timeoutHandle = setTimeout(() => this.serverTimeout(), this.serverTimeoutInMilliseconds);
|
||||
// Set keepAlive timer if there isn't one
|
||||
if (this._pingServerHandle === undefined) {
|
||||
let nextPing = this._nextKeepAlive - new Date().getTime();
|
||||
if (nextPing < 0) {
|
||||
nextPing = 0;
|
||||
}
|
||||
// The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute
|
||||
this._pingServerHandle = setTimeout(async () => {
|
||||
if (this._connectionState === HubConnectionState.Connected) {
|
||||
try {
|
||||
await this._sendMessage(this._cachedPingMessage);
|
||||
}
|
||||
catch {
|
||||
// We don't care about the error. It should be seen elsewhere in the client.
|
||||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering
|
||||
this._cleanupPingTimer();
|
||||
}
|
||||
}
|
||||
}, nextPing);
|
||||
}
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
serverTimeout() {
|
||||
// The server hasn't talked to us in a while. It doesn't like us anymore ... :(
|
||||
// Terminate the connection, but we don't need to wait on the promise. This could trigger reconnecting.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."));
|
||||
}
|
||||
async _invokeClientMethod(invocationMessage) {
|
||||
const methodName = invocationMessage.target.toLowerCase();
|
||||
const methods = this._methods[methodName];
|
||||
if (!methods) {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `No client method with the name '${methodName}' found.`);
|
||||
// No handlers provided by client but the server is expecting a response still, so we send an error
|
||||
if (invocationMessage.invocationId) {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `No result given for '${methodName}' method and invocation ID '${invocationMessage.invocationId}'.`);
|
||||
await this._sendWithProtocol(this._createCompletionMessage(invocationMessage.invocationId, "Client didn't provide a result.", null));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Avoid issues with handlers removing themselves thus modifying the list while iterating through it
|
||||
const methodsCopy = methods.slice();
|
||||
// Server expects a response
|
||||
const expectsResponse = invocationMessage.invocationId ? true : false;
|
||||
// We preserve the last result or exception but still call all handlers
|
||||
let res;
|
||||
let exception;
|
||||
let completionMessage;
|
||||
for (const m of methodsCopy) {
|
||||
try {
|
||||
const prevRes = res;
|
||||
res = await m.apply(this, invocationMessage.arguments);
|
||||
if (expectsResponse && res && prevRes) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Multiple results provided for '${methodName}'. Sending error to server.`);
|
||||
completionMessage = this._createCompletionMessage(invocationMessage.invocationId, `Client provided multiple results.`, null);
|
||||
}
|
||||
// Ignore exception if we got a result after, the exception will be logged
|
||||
exception = undefined;
|
||||
}
|
||||
catch (e) {
|
||||
exception = e;
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `A callback for the method '${methodName}' threw error '${e}'.`);
|
||||
}
|
||||
}
|
||||
if (completionMessage) {
|
||||
await this._sendWithProtocol(completionMessage);
|
||||
}
|
||||
else if (expectsResponse) {
|
||||
// If there is an exception that means either no result was given or a handler after a result threw
|
||||
if (exception) {
|
||||
completionMessage = this._createCompletionMessage(invocationMessage.invocationId, `${exception}`, null);
|
||||
}
|
||||
else if (res !== undefined) {
|
||||
completionMessage = this._createCompletionMessage(invocationMessage.invocationId, null, res);
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `No result given for '${methodName}' method and invocation ID '${invocationMessage.invocationId}'.`);
|
||||
// Client didn't provide a result or throw from a handler, server expects a response so we send an error
|
||||
completionMessage = this._createCompletionMessage(invocationMessage.invocationId, "Client didn't provide a result.", null);
|
||||
}
|
||||
await this._sendWithProtocol(completionMessage);
|
||||
}
|
||||
else {
|
||||
if (res) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Result given for '${methodName}' method but server is not expecting a result.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
_connectionClosed(error) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `HubConnection.connectionClosed(${error}) called while in state ${this._connectionState}.`);
|
||||
// Triggering this.handshakeRejecter is insufficient because it could already be resolved without the continuation having run yet.
|
||||
this._stopDuringStartError = this._stopDuringStartError || error || new Errors_1.AbortError("The underlying connection was closed before the hub handshake could complete.");
|
||||
// If the handshake is in progress, start will be waiting for the handshake promise, so we complete it.
|
||||
// If it has already completed, this should just noop.
|
||||
if (this._handshakeResolver) {
|
||||
this._handshakeResolver();
|
||||
}
|
||||
this._cancelCallbacksWithError(error || new Error("Invocation canceled due to the underlying connection being closed."));
|
||||
this._cleanupTimeout();
|
||||
this._cleanupPingTimer();
|
||||
if (this._connectionState === HubConnectionState.Disconnecting) {
|
||||
this._completeClose(error);
|
||||
}
|
||||
else if (this._connectionState === HubConnectionState.Connected && this._reconnectPolicy) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this._reconnect(error);
|
||||
}
|
||||
else if (this._connectionState === HubConnectionState.Connected) {
|
||||
this._completeClose(error);
|
||||
}
|
||||
// If none of the above if conditions were true were called the HubConnection must be in either:
|
||||
// 1. The Connecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail it.
|
||||
// 2. The Reconnecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail the current reconnect attempt
|
||||
// and potentially continue the reconnect() loop.
|
||||
// 3. The Disconnected state in which case we're already done.
|
||||
}
|
||||
_completeClose(error) {
|
||||
if (this._connectionStarted) {
|
||||
this._connectionState = HubConnectionState.Disconnected;
|
||||
this._connectionStarted = false;
|
||||
if (this._messageBuffer) {
|
||||
this._messageBuffer._dispose(error !== null && error !== void 0 ? error : new Error("Connection closed."));
|
||||
this._messageBuffer = undefined;
|
||||
}
|
||||
if (Utils_1.Platform.isBrowser) {
|
||||
window.document.removeEventListener("freeze", this._freezeEventListener);
|
||||
}
|
||||
try {
|
||||
this._closedCallbacks.forEach((c) => c.apply(this, [error]));
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `An onclose callback called with error '${error}' threw error '${e}'.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
async _reconnect(error) {
|
||||
const reconnectStartTime = Date.now();
|
||||
let previousReconnectAttempts = 0;
|
||||
let retryError = error !== undefined ? error : new Error("Attempting to reconnect due to a unknown error.");
|
||||
let nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, 0, retryError);
|
||||
if (nextRetryDelay === null) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.");
|
||||
this._completeClose(error);
|
||||
return;
|
||||
}
|
||||
this._connectionState = HubConnectionState.Reconnecting;
|
||||
if (error) {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Connection reconnecting because of error '${error}'.`);
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, "Connection reconnecting.");
|
||||
}
|
||||
if (this._reconnectingCallbacks.length !== 0) {
|
||||
try {
|
||||
this._reconnectingCallbacks.forEach((c) => c.apply(this, [error]));
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `An onreconnecting callback called with error '${error}' threw error '${e}'.`);
|
||||
}
|
||||
// Exit early if an onreconnecting callback called connection.stop().
|
||||
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (nextRetryDelay !== null) {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Reconnect attempt number ${previousReconnectAttempts} will start in ${nextRetryDelay} ms.`);
|
||||
await new Promise((resolve) => {
|
||||
this._reconnectDelayHandle = setTimeout(resolve, nextRetryDelay);
|
||||
});
|
||||
this._reconnectDelayHandle = undefined;
|
||||
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this._startInternal();
|
||||
this._connectionState = HubConnectionState.Connected;
|
||||
this._logger.log(ILogger_1.LogLevel.Information, "HubConnection reconnected successfully.");
|
||||
if (this._reconnectedCallbacks.length !== 0) {
|
||||
try {
|
||||
this._reconnectedCallbacks.forEach((c) => c.apply(this, [this.connection.connectionId]));
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Reconnect attempt failed because of error '${e}'.`);
|
||||
if (this._connectionState !== HubConnectionState.Reconnecting) {
|
||||
this._logger.log(ILogger_1.LogLevel.Debug, `Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`);
|
||||
// The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong.
|
||||
if (this._connectionState === HubConnectionState.Disconnecting) {
|
||||
this._completeClose();
|
||||
}
|
||||
return;
|
||||
}
|
||||
retryError = e instanceof Error ? e : new Error(e.toString());
|
||||
nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, Date.now() - reconnectStartTime, retryError);
|
||||
}
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `Reconnect retries have been exhausted after ${Date.now() - reconnectStartTime} ms and ${previousReconnectAttempts} failed attempts. Connection disconnecting.`);
|
||||
this._completeClose();
|
||||
}
|
||||
_getNextRetryDelay(previousRetryCount, elapsedMilliseconds, retryReason) {
|
||||
try {
|
||||
return this._reconnectPolicy.nextRetryDelayInMilliseconds({
|
||||
elapsedMilliseconds,
|
||||
previousRetryCount,
|
||||
retryReason,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `IRetryPolicy.nextRetryDelayInMilliseconds(${previousRetryCount}, ${elapsedMilliseconds}) threw error '${e}'.`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
_cancelCallbacksWithError(error) {
|
||||
const callbacks = this._callbacks;
|
||||
this._callbacks = {};
|
||||
Object.keys(callbacks)
|
||||
.forEach((key) => {
|
||||
const callback = callbacks[key];
|
||||
try {
|
||||
callback(null, error);
|
||||
}
|
||||
catch (e) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `Stream 'error' callback called with '${error}' threw error: ${(0, Utils_1.getErrorString)(e)}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
_cleanupPingTimer() {
|
||||
if (this._pingServerHandle) {
|
||||
clearTimeout(this._pingServerHandle);
|
||||
this._pingServerHandle = undefined;
|
||||
}
|
||||
}
|
||||
_cleanupTimeout() {
|
||||
if (this._timeoutHandle) {
|
||||
clearTimeout(this._timeoutHandle);
|
||||
}
|
||||
}
|
||||
_createInvocation(methodName, args, nonblocking, streamIds) {
|
||||
if (nonblocking) {
|
||||
if (streamIds.length !== 0) {
|
||||
return {
|
||||
arguments: args,
|
||||
streamIds,
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.Invocation,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
arguments: args,
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.Invocation,
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
const invocationId = this._invocationId;
|
||||
this._invocationId++;
|
||||
if (streamIds.length !== 0) {
|
||||
return {
|
||||
arguments: args,
|
||||
invocationId: invocationId.toString(),
|
||||
streamIds,
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.Invocation,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
arguments: args,
|
||||
invocationId: invocationId.toString(),
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.Invocation,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
_launchStreams(streams, promiseQueue) {
|
||||
if (streams.length === 0) {
|
||||
return;
|
||||
}
|
||||
// Synchronize stream data so they arrive in-order on the server
|
||||
if (!promiseQueue) {
|
||||
promiseQueue = Promise.resolve();
|
||||
}
|
||||
// We want to iterate over the keys, since the keys are the stream ids
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (const streamId in streams) {
|
||||
streams[streamId].subscribe({
|
||||
complete: () => {
|
||||
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId)));
|
||||
},
|
||||
error: (err) => {
|
||||
let message;
|
||||
if (err instanceof Error) {
|
||||
message = err.message;
|
||||
}
|
||||
else if (err && err.toString) {
|
||||
message = err.toString();
|
||||
}
|
||||
else {
|
||||
message = "Unknown error";
|
||||
}
|
||||
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId, message)));
|
||||
},
|
||||
next: (item) => {
|
||||
promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createStreamItemMessage(streamId, item)));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
_replaceStreamingParams(args) {
|
||||
const streams = [];
|
||||
const streamIds = [];
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const argument = args[i];
|
||||
if (this._isObservable(argument)) {
|
||||
const streamId = this._invocationId;
|
||||
this._invocationId++;
|
||||
// Store the stream for later use
|
||||
streams[streamId] = argument;
|
||||
streamIds.push(streamId.toString());
|
||||
// remove stream from args
|
||||
args.splice(i, 1);
|
||||
}
|
||||
}
|
||||
return [streams, streamIds];
|
||||
}
|
||||
_isObservable(arg) {
|
||||
// This allows other stream implementations to just work (like rxjs)
|
||||
return arg && arg.subscribe && typeof arg.subscribe === "function";
|
||||
}
|
||||
_createStreamInvocation(methodName, args, streamIds) {
|
||||
const invocationId = this._invocationId;
|
||||
this._invocationId++;
|
||||
if (streamIds.length !== 0) {
|
||||
return {
|
||||
arguments: args,
|
||||
invocationId: invocationId.toString(),
|
||||
streamIds,
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.StreamInvocation,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
arguments: args,
|
||||
invocationId: invocationId.toString(),
|
||||
target: methodName,
|
||||
type: IHubProtocol_1.MessageType.StreamInvocation,
|
||||
};
|
||||
}
|
||||
}
|
||||
_createCancelInvocation(id) {
|
||||
return {
|
||||
invocationId: id,
|
||||
type: IHubProtocol_1.MessageType.CancelInvocation,
|
||||
};
|
||||
}
|
||||
_createStreamItemMessage(id, item) {
|
||||
return {
|
||||
invocationId: id,
|
||||
item,
|
||||
type: IHubProtocol_1.MessageType.StreamItem,
|
||||
};
|
||||
}
|
||||
_createCompletionMessage(id, error, result) {
|
||||
if (error) {
|
||||
return {
|
||||
error,
|
||||
invocationId: id,
|
||||
type: IHubProtocol_1.MessageType.Completion,
|
||||
};
|
||||
}
|
||||
return {
|
||||
invocationId: id,
|
||||
result,
|
||||
type: IHubProtocol_1.MessageType.Completion,
|
||||
};
|
||||
}
|
||||
_createCloseMessage() {
|
||||
return { type: IHubProtocol_1.MessageType.Close };
|
||||
}
|
||||
}
|
||||
exports.HubConnection = HubConnection;
|
||||
//# sourceMappingURL=HubConnection.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnection.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnection.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
148
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnectionBuilder.js
vendored
Normal file
148
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnectionBuilder.js
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HubConnectionBuilder = void 0;
|
||||
const DefaultReconnectPolicy_1 = require("./DefaultReconnectPolicy");
|
||||
const HttpConnection_1 = require("./HttpConnection");
|
||||
const HubConnection_1 = require("./HubConnection");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const JsonHubProtocol_1 = require("./JsonHubProtocol");
|
||||
const Loggers_1 = require("./Loggers");
|
||||
const Utils_1 = require("./Utils");
|
||||
const LogLevelNameMapping = {
|
||||
trace: ILogger_1.LogLevel.Trace,
|
||||
debug: ILogger_1.LogLevel.Debug,
|
||||
info: ILogger_1.LogLevel.Information,
|
||||
information: ILogger_1.LogLevel.Information,
|
||||
warn: ILogger_1.LogLevel.Warning,
|
||||
warning: ILogger_1.LogLevel.Warning,
|
||||
error: ILogger_1.LogLevel.Error,
|
||||
critical: ILogger_1.LogLevel.Critical,
|
||||
none: ILogger_1.LogLevel.None,
|
||||
};
|
||||
function parseLogLevel(name) {
|
||||
// Case-insensitive matching via lower-casing
|
||||
// Yes, I know case-folding is a complicated problem in Unicode, but we only support
|
||||
// the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.
|
||||
const mapping = LogLevelNameMapping[name.toLowerCase()];
|
||||
if (typeof mapping !== "undefined") {
|
||||
return mapping;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Unknown log level: ${name}`);
|
||||
}
|
||||
}
|
||||
/** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
|
||||
class HubConnectionBuilder {
|
||||
configureLogging(logging) {
|
||||
Utils_1.Arg.isRequired(logging, "logging");
|
||||
if (isLogger(logging)) {
|
||||
this.logger = logging;
|
||||
}
|
||||
else if (typeof logging === "string") {
|
||||
const logLevel = parseLogLevel(logging);
|
||||
this.logger = new Utils_1.ConsoleLogger(logLevel);
|
||||
}
|
||||
else {
|
||||
this.logger = new Utils_1.ConsoleLogger(logging);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
withUrl(url, transportTypeOrOptions) {
|
||||
Utils_1.Arg.isRequired(url, "url");
|
||||
Utils_1.Arg.isNotEmpty(url, "url");
|
||||
this.url = url;
|
||||
// Flow-typing knows where it's at. Since HttpTransportType is a number and IHttpConnectionOptions is guaranteed
|
||||
// to be an object, we know (as does TypeScript) this comparison is all we need to figure out which overload was called.
|
||||
if (typeof transportTypeOrOptions === "object") {
|
||||
this.httpConnectionOptions = { ...this.httpConnectionOptions, ...transportTypeOrOptions };
|
||||
}
|
||||
else {
|
||||
this.httpConnectionOptions = {
|
||||
...this.httpConnectionOptions,
|
||||
transport: transportTypeOrOptions,
|
||||
};
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
|
||||
*
|
||||
* @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
|
||||
*/
|
||||
withHubProtocol(protocol) {
|
||||
Utils_1.Arg.isRequired(protocol, "protocol");
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
withAutomaticReconnect(retryDelaysOrReconnectPolicy) {
|
||||
if (this.reconnectPolicy) {
|
||||
throw new Error("A reconnectPolicy has already been set.");
|
||||
}
|
||||
if (!retryDelaysOrReconnectPolicy) {
|
||||
this.reconnectPolicy = new DefaultReconnectPolicy_1.DefaultReconnectPolicy();
|
||||
}
|
||||
else if (Array.isArray(retryDelaysOrReconnectPolicy)) {
|
||||
this.reconnectPolicy = new DefaultReconnectPolicy_1.DefaultReconnectPolicy(retryDelaysOrReconnectPolicy);
|
||||
}
|
||||
else {
|
||||
this.reconnectPolicy = retryDelaysOrReconnectPolicy;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/** Configures {@link @microsoft/signalr.HubConnection.serverTimeoutInMilliseconds} for the {@link @microsoft/signalr.HubConnection}.
|
||||
*
|
||||
* @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
|
||||
*/
|
||||
withServerTimeout(milliseconds) {
|
||||
Utils_1.Arg.isRequired(milliseconds, "milliseconds");
|
||||
this._serverTimeoutInMilliseconds = milliseconds;
|
||||
return this;
|
||||
}
|
||||
/** Configures {@link @microsoft/signalr.HubConnection.keepAliveIntervalInMilliseconds} for the {@link @microsoft/signalr.HubConnection}.
|
||||
*
|
||||
* @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
|
||||
*/
|
||||
withKeepAliveInterval(milliseconds) {
|
||||
Utils_1.Arg.isRequired(milliseconds, "milliseconds");
|
||||
this._keepAliveIntervalInMilliseconds = milliseconds;
|
||||
return this;
|
||||
}
|
||||
/** Enables and configures options for the Stateful Reconnect feature.
|
||||
*
|
||||
* @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
|
||||
*/
|
||||
withStatefulReconnect(options) {
|
||||
if (this.httpConnectionOptions === undefined) {
|
||||
this.httpConnectionOptions = {};
|
||||
}
|
||||
this.httpConnectionOptions._useStatefulReconnect = true;
|
||||
this._statefulReconnectBufferSize = options === null || options === void 0 ? void 0 : options.bufferSize;
|
||||
return this;
|
||||
}
|
||||
/** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
|
||||
*
|
||||
* @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
|
||||
*/
|
||||
build() {
|
||||
// If httpConnectionOptions has a logger, use it. Otherwise, override it with the one
|
||||
// provided to configureLogger
|
||||
const httpConnectionOptions = this.httpConnectionOptions || {};
|
||||
// If it's 'null', the user **explicitly** asked for null, don't mess with it.
|
||||
if (httpConnectionOptions.logger === undefined) {
|
||||
// If our logger is undefined or null, that's OK, the HttpConnection constructor will handle it.
|
||||
httpConnectionOptions.logger = this.logger;
|
||||
}
|
||||
// Now create the connection
|
||||
if (!this.url) {
|
||||
throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
|
||||
}
|
||||
const connection = new HttpConnection_1.HttpConnection(this.url, httpConnectionOptions);
|
||||
return HubConnection_1.HubConnection.create(connection, this.logger || Loggers_1.NullLogger.instance, this.protocol || new JsonHubProtocol_1.JsonHubProtocol(), this.reconnectPolicy, this._serverTimeoutInMilliseconds, this._keepAliveIntervalInMilliseconds, this._statefulReconnectBufferSize);
|
||||
}
|
||||
}
|
||||
exports.HubConnectionBuilder = HubConnectionBuilder;
|
||||
function isLogger(logger) {
|
||||
return logger.log !== undefined;
|
||||
}
|
||||
//# sourceMappingURL=HubConnectionBuilder.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnectionBuilder.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/HubConnectionBuilder.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IConnection.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IConnection.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IConnection.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IConnection.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IConnection.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"IConnection.js","sourceRoot":"","sources":["../../src/IConnection.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { TransferFormat } from \"./ITransport\";\r\n\r\n/** @private */\r\nexport interface IConnection {\r\n readonly features: any;\r\n readonly connectionId?: string;\r\n\r\n baseUrl: string;\r\n\r\n start(transferFormat: TransferFormat): Promise<void>;\r\n send(data: string | ArrayBuffer): Promise<void>;\r\n stop(error?: Error | unknown): Promise<void>;\r\n\r\n onreceive: ((data: string | ArrayBuffer) => void) | null;\r\n onclose: ((error?: Error) => void) | null;\r\n}\r\n"]}
|
||||
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHttpConnectionOptions.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHttpConnectionOptions.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IHttpConnectionOptions.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHttpConnectionOptions.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHttpConnectionOptions.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"IHttpConnectionOptions.js","sourceRoot":"","sources":["../../src/IHttpConnectionOptions.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { HttpClient } from \"./HttpClient\";\r\nimport { MessageHeaders } from \"./IHubProtocol\";\r\nimport { ILogger, LogLevel } from \"./ILogger\";\r\nimport { HttpTransportType, ITransport } from \"./ITransport\";\r\nimport { EventSourceConstructor, WebSocketConstructor } from \"./Polyfills\";\r\n\r\n/** Options provided to the 'withUrl' method on {@link @microsoft/signalr.HubConnectionBuilder} to configure options for the HTTP-based transports. */\r\nexport interface IHttpConnectionOptions {\r\n /** {@link @microsoft/signalr.MessageHeaders} containing custom headers to be sent with every HTTP request. Note, setting headers in the browser will not work for WebSockets or the ServerSentEvents stream. */\r\n headers?: MessageHeaders;\r\n\r\n /** An {@link @microsoft/signalr.HttpClient} that will be used to make HTTP requests. */\r\n httpClient?: HttpClient;\r\n\r\n /** An {@link @microsoft/signalr.HttpTransportType} value specifying the transport to use for the connection. */\r\n transport?: HttpTransportType | ITransport;\r\n\r\n /** Configures the logger used for logging.\r\n *\r\n * Provide an {@link @microsoft/signalr.ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from\r\n * the {@link @microsoft/signalr.LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified\r\n * level (or higher).\r\n */\r\n logger?: ILogger | LogLevel;\r\n\r\n /** A function that provides an access token required for HTTP Bearer authentication.\r\n *\r\n * @returns {string | Promise<string>} A string containing the access token, or a Promise that resolves to a string containing the access token.\r\n */\r\n accessTokenFactory?(): string | Promise<string>;\r\n\r\n /** A boolean indicating if message content should be logged.\r\n *\r\n * Message content can contain sensitive user data, so this is disabled by default.\r\n */\r\n logMessageContent?: boolean;\r\n\r\n /** A boolean indicating if negotiation should be skipped.\r\n *\r\n * Negotiation can only be skipped when the {@link @microsoft/signalr.IHttpConnectionOptions.transport} property is set to 'HttpTransportType.WebSockets'.\r\n */\r\n skipNegotiation?: boolean;\r\n\r\n // Used for unit testing and code spelunkers\r\n /** A constructor that can be used to create a WebSocket.\r\n *\r\n * @internal\r\n */\r\n WebSocket?: WebSocketConstructor;\r\n\r\n // Used for unit testing and code spelunkers\r\n /** A constructor that can be used to create an EventSource.\r\n *\r\n * @internal\r\n */\r\n EventSource?: EventSourceConstructor;\r\n\r\n /**\r\n * Default value is 'true'.\r\n * This controls whether credentials such as cookies are sent in cross-site requests.\r\n *\r\n * Cookies are used by many load-balancers for sticky sessions which is required when your app is deployed with multiple servers.\r\n */\r\n withCredentials?: boolean;\r\n\r\n /**\r\n * Default value is 100,000 milliseconds.\r\n * Timeout to apply to Http requests.\r\n *\r\n * This will not apply to Long Polling poll requests, EventSource, or WebSockets.\r\n */\r\n timeout?: number;\r\n\r\n // Internal, should be set by {@link @microsoft/signalr.HubConnectionBuilder.withStatefulReconnect}\r\n /** Specifies that the client should use Stateful Reconnect. It will try to reconnect with the same connection token.\r\n *\r\n * @internal\r\n */\r\n _useStatefulReconnect?: boolean;\r\n}\r\n"]}
|
||||
26
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHubProtocol.js
vendored
Normal file
26
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHubProtocol.js
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MessageType = void 0;
|
||||
/** Defines the type of a Hub Message. */
|
||||
var MessageType;
|
||||
(function (MessageType) {
|
||||
/** Indicates the message is an Invocation message and implements the {@link @microsoft/signalr.InvocationMessage} interface. */
|
||||
MessageType[MessageType["Invocation"] = 1] = "Invocation";
|
||||
/** Indicates the message is a StreamItem message and implements the {@link @microsoft/signalr.StreamItemMessage} interface. */
|
||||
MessageType[MessageType["StreamItem"] = 2] = "StreamItem";
|
||||
/** Indicates the message is a Completion message and implements the {@link @microsoft/signalr.CompletionMessage} interface. */
|
||||
MessageType[MessageType["Completion"] = 3] = "Completion";
|
||||
/** Indicates the message is a Stream Invocation message and implements the {@link @microsoft/signalr.StreamInvocationMessage} interface. */
|
||||
MessageType[MessageType["StreamInvocation"] = 4] = "StreamInvocation";
|
||||
/** Indicates the message is a Cancel Invocation message and implements the {@link @microsoft/signalr.CancelInvocationMessage} interface. */
|
||||
MessageType[MessageType["CancelInvocation"] = 5] = "CancelInvocation";
|
||||
/** Indicates the message is a Ping message and implements the {@link @microsoft/signalr.PingMessage} interface. */
|
||||
MessageType[MessageType["Ping"] = 6] = "Ping";
|
||||
/** Indicates the message is a Close message and implements the {@link @microsoft/signalr.CloseMessage} interface. */
|
||||
MessageType[MessageType["Close"] = 7] = "Close";
|
||||
MessageType[MessageType["Ack"] = 8] = "Ack";
|
||||
MessageType[MessageType["Sequence"] = 9] = "Sequence";
|
||||
})(MessageType = exports.MessageType || (exports.MessageType = {}));
|
||||
//# sourceMappingURL=IHubProtocol.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHubProtocol.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IHubProtocol.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
28
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ILogger.js
vendored
Normal file
28
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ILogger.js
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LogLevel = void 0;
|
||||
// These values are designed to match the ASP.NET Log Levels since that's the pattern we're emulating here.
|
||||
/** Indicates the severity of a log message.
|
||||
*
|
||||
* Log Levels are ordered in increasing severity. So `Debug` is more severe than `Trace`, etc.
|
||||
*/
|
||||
var LogLevel;
|
||||
(function (LogLevel) {
|
||||
/** Log level for very low severity diagnostic messages. */
|
||||
LogLevel[LogLevel["Trace"] = 0] = "Trace";
|
||||
/** Log level for low severity diagnostic messages. */
|
||||
LogLevel[LogLevel["Debug"] = 1] = "Debug";
|
||||
/** Log level for informational diagnostic messages. */
|
||||
LogLevel[LogLevel["Information"] = 2] = "Information";
|
||||
/** Log level for diagnostic messages that indicate a non-fatal problem. */
|
||||
LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
||||
/** Log level for diagnostic messages that indicate a failure in the current operation. */
|
||||
LogLevel[LogLevel["Error"] = 4] = "Error";
|
||||
/** Log level for diagnostic messages that indicate a failure that will terminate the entire application. */
|
||||
LogLevel[LogLevel["Critical"] = 5] = "Critical";
|
||||
/** The highest possible log level. Used when configuring logging to indicate that no log messages should be emitted. */
|
||||
LogLevel[LogLevel["None"] = 6] = "None";
|
||||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
||||
//# sourceMappingURL=ILogger.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ILogger.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ILogger.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ILogger.js","sourceRoot":"","sources":["../../src/ILogger.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,2GAA2G;AAC3G;;;GAGG;AACH,IAAY,QAeX;AAfD,WAAY,QAAQ;IAChB,2DAA2D;IAC3D,yCAAS,CAAA;IACT,sDAAsD;IACtD,yCAAS,CAAA;IACT,uDAAuD;IACvD,qDAAe,CAAA;IACf,2EAA2E;IAC3E,6CAAW,CAAA;IACX,0FAA0F;IAC1F,yCAAS,CAAA;IACT,4GAA4G;IAC5G,+CAAY,CAAA;IACZ,wHAAwH;IACxH,uCAAQ,CAAA;AACZ,CAAC,EAfW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAenB","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// These values are designed to match the ASP.NET Log Levels since that's the pattern we're emulating here.\r\n/** Indicates the severity of a log message.\r\n *\r\n * Log Levels are ordered in increasing severity. So `Debug` is more severe than `Trace`, etc.\r\n */\r\nexport enum LogLevel {\r\n /** Log level for very low severity diagnostic messages. */\r\n Trace = 0,\r\n /** Log level for low severity diagnostic messages. */\r\n Debug = 1,\r\n /** Log level for informational diagnostic messages. */\r\n Information = 2,\r\n /** Log level for diagnostic messages that indicate a non-fatal problem. */\r\n Warning = 3,\r\n /** Log level for diagnostic messages that indicate a failure in the current operation. */\r\n Error = 4,\r\n /** Log level for diagnostic messages that indicate a failure that will terminate the entire application. */\r\n Critical = 5,\r\n /** The highest possible log level. Used when configuring logging to indicate that no log messages should be emitted. */\r\n None = 6,\r\n}\r\n\r\n/** An abstraction that provides a sink for diagnostic messages. */\r\nexport interface ILogger {\r\n /** Called by the framework to emit a diagnostic message.\r\n *\r\n * @param {LogLevel} logLevel The severity level of the message.\r\n * @param {string} message The message.\r\n */\r\n log(logLevel: LogLevel, message: string): void;\r\n}\r\n"]}
|
||||
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IRetryPolicy.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IRetryPolicy.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IRetryPolicy.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IRetryPolicy.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IRetryPolicy.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"IRetryPolicy.js","sourceRoot":"","sources":["../../src/IRetryPolicy.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n/** An abstraction that controls when the client attempts to reconnect and how many times it does so. */\r\nexport interface IRetryPolicy {\r\n /** Called after the transport loses the connection.\r\n *\r\n * @param {RetryContext} retryContext Details related to the retry event to help determine how long to wait for the next retry.\r\n *\r\n * @returns {number | null} The amount of time in milliseconds to wait before the next retry. `null` tells the client to stop retrying.\r\n */\r\n nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null;\r\n}\r\n\r\nexport interface RetryContext {\r\n /**\r\n * The number of consecutive failed tries so far.\r\n */\r\n readonly previousRetryCount: number;\r\n\r\n /**\r\n * The amount of time in milliseconds spent retrying so far.\r\n */\r\n readonly elapsedMilliseconds: number;\r\n\r\n /**\r\n * The error that forced the upcoming retry.\r\n */\r\n readonly retryReason: Error;\r\n}\r\n"]}
|
||||
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IStatefulReconnectOptions.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IStatefulReconnectOptions.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IStatefulReconnectOptions.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IStatefulReconnectOptions.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/IStatefulReconnectOptions.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"IStatefulReconnectOptions.js","sourceRoot":"","sources":["../../src/IStatefulReconnectOptions.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n/** Options provided to the 'withStatefulReconnect' method on {@link @microsoft/signalr.HubConnectionBuilder} to configure options for Stateful Reconnect. */\r\nexport interface IStatefulReconnectOptions {\r\n /** Amount of bytes we'll buffer when using Stateful Reconnect until applying backpressure to sends from the client. */\r\n bufferSize: number;\r\n}"]}
|
||||
27
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ITransport.js
vendored
Normal file
27
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ITransport.js
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TransferFormat = exports.HttpTransportType = void 0;
|
||||
// This will be treated as a bit flag in the future, so we keep it using power-of-two values.
|
||||
/** Specifies a specific HTTP transport type. */
|
||||
var HttpTransportType;
|
||||
(function (HttpTransportType) {
|
||||
/** Specifies no transport preference. */
|
||||
HttpTransportType[HttpTransportType["None"] = 0] = "None";
|
||||
/** Specifies the WebSockets transport. */
|
||||
HttpTransportType[HttpTransportType["WebSockets"] = 1] = "WebSockets";
|
||||
/** Specifies the Server-Sent Events transport. */
|
||||
HttpTransportType[HttpTransportType["ServerSentEvents"] = 2] = "ServerSentEvents";
|
||||
/** Specifies the Long Polling transport. */
|
||||
HttpTransportType[HttpTransportType["LongPolling"] = 4] = "LongPolling";
|
||||
})(HttpTransportType = exports.HttpTransportType || (exports.HttpTransportType = {}));
|
||||
/** Specifies the transfer format for a connection. */
|
||||
var TransferFormat;
|
||||
(function (TransferFormat) {
|
||||
/** Specifies that only text data will be transmitted over the connection. */
|
||||
TransferFormat[TransferFormat["Text"] = 1] = "Text";
|
||||
/** Specifies that binary data will be transmitted over the connection. */
|
||||
TransferFormat[TransferFormat["Binary"] = 2] = "Binary";
|
||||
})(TransferFormat = exports.TransferFormat || (exports.TransferFormat = {}));
|
||||
//# sourceMappingURL=ITransport.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ITransport.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ITransport.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ITransport.js","sourceRoot":"","sources":["../../src/ITransport.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,6FAA6F;AAC7F,gDAAgD;AAChD,IAAY,iBASX;AATD,WAAY,iBAAiB;IACzB,yCAAyC;IACzC,yDAAQ,CAAA;IACR,0CAA0C;IAC1C,qEAAc,CAAA;IACd,kDAAkD;IAClD,iFAAoB,CAAA;IACpB,4CAA4C;IAC5C,uEAAe,CAAA;AACnB,CAAC,EATW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAS5B;AAED,sDAAsD;AACtD,IAAY,cAKX;AALD,WAAY,cAAc;IACtB,6EAA6E;IAC7E,mDAAQ,CAAA;IACR,0EAA0E;IAC1E,uDAAU,CAAA;AACd,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// This will be treated as a bit flag in the future, so we keep it using power-of-two values.\r\n/** Specifies a specific HTTP transport type. */\r\nexport enum HttpTransportType {\r\n /** Specifies no transport preference. */\r\n None = 0,\r\n /** Specifies the WebSockets transport. */\r\n WebSockets = 1,\r\n /** Specifies the Server-Sent Events transport. */\r\n ServerSentEvents = 2,\r\n /** Specifies the Long Polling transport. */\r\n LongPolling = 4,\r\n}\r\n\r\n/** Specifies the transfer format for a connection. */\r\nexport enum TransferFormat {\r\n /** Specifies that only text data will be transmitted over the connection. */\r\n Text = 1,\r\n /** Specifies that binary data will be transmitted over the connection. */\r\n Binary = 2,\r\n}\r\n\r\n/** An abstraction over the behavior of transports. This is designed to support the framework and not intended for use by applications. */\r\nexport interface ITransport {\r\n connect(url: string, transferFormat: TransferFormat): Promise<void>;\r\n send(data: any): Promise<void>;\r\n stop(): Promise<void>;\r\n onreceive: ((data: string | ArrayBuffer) => void) | null;\r\n onclose: ((error?: Error) => void) | null;\r\n}\r\n"]}
|
||||
123
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/JsonHubProtocol.js
vendored
Normal file
123
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/JsonHubProtocol.js
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JsonHubProtocol = void 0;
|
||||
const IHubProtocol_1 = require("./IHubProtocol");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const ITransport_1 = require("./ITransport");
|
||||
const Loggers_1 = require("./Loggers");
|
||||
const TextMessageFormat_1 = require("./TextMessageFormat");
|
||||
const JSON_HUB_PROTOCOL_NAME = "json";
|
||||
/** Implements the JSON Hub Protocol. */
|
||||
class JsonHubProtocol {
|
||||
constructor() {
|
||||
/** @inheritDoc */
|
||||
this.name = JSON_HUB_PROTOCOL_NAME;
|
||||
/** @inheritDoc */
|
||||
this.version = 2;
|
||||
/** @inheritDoc */
|
||||
this.transferFormat = ITransport_1.TransferFormat.Text;
|
||||
}
|
||||
/** Creates an array of {@link @microsoft/signalr.HubMessage} objects from the specified serialized representation.
|
||||
*
|
||||
* @param {string} input A string containing the serialized representation.
|
||||
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
|
||||
*/
|
||||
parseMessages(input, logger) {
|
||||
// The interface does allow "ArrayBuffer" to be passed in, but this implementation does not. So let's throw a useful error.
|
||||
if (typeof input !== "string") {
|
||||
throw new Error("Invalid input for JSON hub protocol. Expected a string.");
|
||||
}
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
if (logger === null) {
|
||||
logger = Loggers_1.NullLogger.instance;
|
||||
}
|
||||
// Parse the messages
|
||||
const messages = TextMessageFormat_1.TextMessageFormat.parse(input);
|
||||
const hubMessages = [];
|
||||
for (const message of messages) {
|
||||
const parsedMessage = JSON.parse(message);
|
||||
if (typeof parsedMessage.type !== "number") {
|
||||
throw new Error("Invalid payload.");
|
||||
}
|
||||
switch (parsedMessage.type) {
|
||||
case IHubProtocol_1.MessageType.Invocation:
|
||||
this._isInvocationMessage(parsedMessage);
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.StreamItem:
|
||||
this._isStreamItemMessage(parsedMessage);
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Completion:
|
||||
this._isCompletionMessage(parsedMessage);
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Ping:
|
||||
// Single value, no need to validate
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Close:
|
||||
// All optional values, no need to validate
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Ack:
|
||||
this._isAckMessage(parsedMessage);
|
||||
break;
|
||||
case IHubProtocol_1.MessageType.Sequence:
|
||||
this._isSequenceMessage(parsedMessage);
|
||||
break;
|
||||
default:
|
||||
// Future protocol changes can add message types, old clients can ignore them
|
||||
logger.log(ILogger_1.LogLevel.Information, "Unknown message type '" + parsedMessage.type + "' ignored.");
|
||||
continue;
|
||||
}
|
||||
hubMessages.push(parsedMessage);
|
||||
}
|
||||
return hubMessages;
|
||||
}
|
||||
/** Writes the specified {@link @microsoft/signalr.HubMessage} to a string and returns it.
|
||||
*
|
||||
* @param {HubMessage} message The message to write.
|
||||
* @returns {string} A string containing the serialized representation of the message.
|
||||
*/
|
||||
writeMessage(message) {
|
||||
return TextMessageFormat_1.TextMessageFormat.write(JSON.stringify(message));
|
||||
}
|
||||
_isInvocationMessage(message) {
|
||||
this._assertNotEmptyString(message.target, "Invalid payload for Invocation message.");
|
||||
if (message.invocationId !== undefined) {
|
||||
this._assertNotEmptyString(message.invocationId, "Invalid payload for Invocation message.");
|
||||
}
|
||||
}
|
||||
_isStreamItemMessage(message) {
|
||||
this._assertNotEmptyString(message.invocationId, "Invalid payload for StreamItem message.");
|
||||
if (message.item === undefined) {
|
||||
throw new Error("Invalid payload for StreamItem message.");
|
||||
}
|
||||
}
|
||||
_isCompletionMessage(message) {
|
||||
if (message.result && message.error) {
|
||||
throw new Error("Invalid payload for Completion message.");
|
||||
}
|
||||
if (!message.result && message.error) {
|
||||
this._assertNotEmptyString(message.error, "Invalid payload for Completion message.");
|
||||
}
|
||||
this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
|
||||
}
|
||||
_isAckMessage(message) {
|
||||
if (typeof message.sequenceId !== 'number') {
|
||||
throw new Error("Invalid SequenceId for Ack message.");
|
||||
}
|
||||
}
|
||||
_isSequenceMessage(message) {
|
||||
if (typeof message.sequenceId !== 'number') {
|
||||
throw new Error("Invalid SequenceId for Sequence message.");
|
||||
}
|
||||
}
|
||||
_assertNotEmptyString(value, errorMessage) {
|
||||
if (typeof value !== "string" || value === "") {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.JsonHubProtocol = JsonHubProtocol;
|
||||
//# sourceMappingURL=JsonHubProtocol.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/JsonHubProtocol.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/JsonHubProtocol.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
17
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Loggers.js
vendored
Normal file
17
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Loggers.js
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NullLogger = void 0;
|
||||
/** A logger that does nothing when log messages are sent to it. */
|
||||
class NullLogger {
|
||||
constructor() { }
|
||||
/** @inheritDoc */
|
||||
// eslint-disable-next-line
|
||||
log(_logLevel, _message) {
|
||||
}
|
||||
}
|
||||
exports.NullLogger = NullLogger;
|
||||
/** The singleton instance of the {@link @microsoft/signalr.NullLogger}. */
|
||||
NullLogger.instance = new NullLogger();
|
||||
//# sourceMappingURL=Loggers.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Loggers.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Loggers.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Loggers.js","sourceRoot":"","sources":["../../src/Loggers.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAIvE,mEAAmE;AACnE,MAAa,UAAU;IAInB,gBAAuB,CAAC;IAExB,kBAAkB;IAClB,2BAA2B;IACpB,GAAG,CAAC,SAAmB,EAAE,QAAgB;IAChD,CAAC;;AATL,gCAUC;AATG,2EAA2E;AAC7D,mBAAQ,GAAY,IAAI,UAAU,EAAE,CAAC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { ILogger, LogLevel } from \"./ILogger\";\r\n\r\n/** A logger that does nothing when log messages are sent to it. */\r\nexport class NullLogger implements ILogger {\r\n /** The singleton instance of the {@link @microsoft/signalr.NullLogger}. */\r\n public static instance: ILogger = new NullLogger();\r\n\r\n private constructor() {}\r\n\r\n /** @inheritDoc */\r\n // eslint-disable-next-line\r\n public log(_logLevel: LogLevel, _message: string): void {\r\n }\r\n}\r\n"]}
|
||||
187
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/LongPollingTransport.js
vendored
Normal file
187
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/LongPollingTransport.js
vendored
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LongPollingTransport = void 0;
|
||||
const AbortController_1 = require("./AbortController");
|
||||
const Errors_1 = require("./Errors");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const ITransport_1 = require("./ITransport");
|
||||
const Utils_1 = require("./Utils");
|
||||
// Not exported from 'index', this type is internal.
|
||||
/** @private */
|
||||
class LongPollingTransport {
|
||||
// This is an internal type, not exported from 'index' so this is really just internal.
|
||||
get pollAborted() {
|
||||
return this._pollAbort.aborted;
|
||||
}
|
||||
constructor(httpClient, logger, options) {
|
||||
this._httpClient = httpClient;
|
||||
this._logger = logger;
|
||||
this._pollAbort = new AbortController_1.AbortController();
|
||||
this._options = options;
|
||||
this._running = false;
|
||||
this.onreceive = null;
|
||||
this.onclose = null;
|
||||
}
|
||||
async connect(url, transferFormat) {
|
||||
Utils_1.Arg.isRequired(url, "url");
|
||||
Utils_1.Arg.isRequired(transferFormat, "transferFormat");
|
||||
Utils_1.Arg.isIn(transferFormat, ITransport_1.TransferFormat, "transferFormat");
|
||||
this._url = url;
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Connecting.");
|
||||
// Allow binary format on Node and Browsers that support binary content (indicated by the presence of responseType property)
|
||||
if (transferFormat === ITransport_1.TransferFormat.Binary &&
|
||||
(typeof XMLHttpRequest !== "undefined" && typeof new XMLHttpRequest().responseType !== "string")) {
|
||||
throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
|
||||
}
|
||||
const [name, value] = (0, Utils_1.getUserAgentHeader)();
|
||||
const headers = { [name]: value, ...this._options.headers };
|
||||
const pollOptions = {
|
||||
abortSignal: this._pollAbort.signal,
|
||||
headers,
|
||||
timeout: 100000,
|
||||
withCredentials: this._options.withCredentials,
|
||||
};
|
||||
if (transferFormat === ITransport_1.TransferFormat.Binary) {
|
||||
pollOptions.responseType = "arraybuffer";
|
||||
}
|
||||
// Make initial long polling request
|
||||
// Server uses first long polling request to finish initializing connection and it returns without data
|
||||
const pollUrl = `${url}&_=${Date.now()}`;
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
|
||||
const response = await this._httpClient.get(pollUrl, pollOptions);
|
||||
if (response.statusCode !== 200) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
|
||||
// Mark running as false so that the poll immediately ends and runs the close logic
|
||||
this._closeError = new Errors_1.HttpError(response.statusText || "", response.statusCode);
|
||||
this._running = false;
|
||||
}
|
||||
else {
|
||||
this._running = true;
|
||||
}
|
||||
this._receiving = this._poll(this._url, pollOptions);
|
||||
}
|
||||
async _poll(url, pollOptions) {
|
||||
try {
|
||||
while (this._running) {
|
||||
try {
|
||||
const pollUrl = `${url}&_=${Date.now()}`;
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
|
||||
const response = await this._httpClient.get(pollUrl, pollOptions);
|
||||
if (response.statusCode === 204) {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, "(LongPolling transport) Poll terminated by server.");
|
||||
this._running = false;
|
||||
}
|
||||
else if (response.statusCode !== 200) {
|
||||
this._logger.log(ILogger_1.LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
|
||||
// Unexpected status code
|
||||
this._closeError = new Errors_1.HttpError(response.statusText || "", response.statusCode);
|
||||
this._running = false;
|
||||
}
|
||||
else {
|
||||
// Process the response
|
||||
if (response.content) {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) data received. ${(0, Utils_1.getDataDetail)(response.content, this._options.logMessageContent)}.`);
|
||||
if (this.onreceive) {
|
||||
this.onreceive(response.content);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This is another way timeout manifest.
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (!this._running) {
|
||||
// Log but disregard errors that occur after stopping
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) Poll errored after shutdown: ${e.message}`);
|
||||
}
|
||||
else {
|
||||
if (e instanceof Errors_1.TimeoutError) {
|
||||
// Ignore timeouts and reissue the poll.
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
|
||||
}
|
||||
else {
|
||||
// Close the connection with the error as the result.
|
||||
this._closeError = e;
|
||||
this._running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Polling complete.");
|
||||
// We will reach here with pollAborted==false when the server returned a response causing the transport to stop.
|
||||
// If pollAborted==true then client initiated the stop and the stop method will raise the close event after DELETE is sent.
|
||||
if (!this.pollAborted) {
|
||||
this._raiseOnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
async send(data) {
|
||||
if (!this._running) {
|
||||
return Promise.reject(new Error("Cannot send until the transport is connected"));
|
||||
}
|
||||
return (0, Utils_1.sendMessage)(this._logger, "LongPolling", this._httpClient, this._url, data, this._options);
|
||||
}
|
||||
async stop() {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Stopping polling.");
|
||||
// Tell receiving loop to stop, abort any current request, and then wait for it to finish
|
||||
this._running = false;
|
||||
this._pollAbort.abort();
|
||||
try {
|
||||
await this._receiving;
|
||||
// Send DELETE to clean up long polling on the server
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) sending DELETE request to ${this._url}.`);
|
||||
const headers = {};
|
||||
const [name, value] = (0, Utils_1.getUserAgentHeader)();
|
||||
headers[name] = value;
|
||||
const deleteOptions = {
|
||||
headers: { ...headers, ...this._options.headers },
|
||||
timeout: this._options.timeout,
|
||||
withCredentials: this._options.withCredentials,
|
||||
};
|
||||
let error;
|
||||
try {
|
||||
await this._httpClient.delete(this._url, deleteOptions);
|
||||
}
|
||||
catch (err) {
|
||||
error = err;
|
||||
}
|
||||
if (error) {
|
||||
if (error instanceof Errors_1.HttpError) {
|
||||
if (error.statusCode === 404) {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) A 404 response was returned from sending a DELETE request.");
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(LongPolling transport) Error sending a DELETE request: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) DELETE request accepted.");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(LongPolling transport) Stop finished.");
|
||||
// Raise close event here instead of in polling
|
||||
// It needs to happen after the DELETE request is sent
|
||||
this._raiseOnClose();
|
||||
}
|
||||
}
|
||||
_raiseOnClose() {
|
||||
if (this.onclose) {
|
||||
let logMessage = "(LongPolling transport) Firing onclose event.";
|
||||
if (this._closeError) {
|
||||
logMessage += " Error: " + this._closeError;
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, logMessage);
|
||||
this.onclose(this._closeError);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.LongPollingTransport = LongPollingTransport;
|
||||
//# sourceMappingURL=LongPollingTransport.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/LongPollingTransport.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/LongPollingTransport.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
198
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/MessageBuffer.js
vendored
Normal file
198
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/MessageBuffer.js
vendored
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MessageBuffer = void 0;
|
||||
const IHubProtocol_1 = require("./IHubProtocol");
|
||||
const Utils_1 = require("./Utils");
|
||||
/** @private */
|
||||
class MessageBuffer {
|
||||
constructor(protocol, connection, bufferSize) {
|
||||
this._bufferSize = 100000;
|
||||
this._messages = [];
|
||||
this._totalMessageCount = 0;
|
||||
this._waitForSequenceMessage = false;
|
||||
// Message IDs start at 1 and always increment by 1
|
||||
this._nextReceivingSequenceId = 1;
|
||||
this._latestReceivedSequenceId = 0;
|
||||
this._bufferedByteCount = 0;
|
||||
this._reconnectInProgress = false;
|
||||
this._protocol = protocol;
|
||||
this._connection = connection;
|
||||
this._bufferSize = bufferSize;
|
||||
}
|
||||
async _send(message) {
|
||||
const serializedMessage = this._protocol.writeMessage(message);
|
||||
let backpressurePromise = Promise.resolve();
|
||||
// Only count invocation messages. Acks, pings, etc. don't need to be resent on reconnect
|
||||
if (this._isInvocationMessage(message)) {
|
||||
this._totalMessageCount++;
|
||||
let backpressurePromiseResolver = () => { };
|
||||
let backpressurePromiseRejector = () => { };
|
||||
if ((0, Utils_1.isArrayBuffer)(serializedMessage)) {
|
||||
this._bufferedByteCount += serializedMessage.byteLength;
|
||||
}
|
||||
else {
|
||||
this._bufferedByteCount += serializedMessage.length;
|
||||
}
|
||||
if (this._bufferedByteCount >= this._bufferSize) {
|
||||
backpressurePromise = new Promise((resolve, reject) => {
|
||||
backpressurePromiseResolver = resolve;
|
||||
backpressurePromiseRejector = reject;
|
||||
});
|
||||
}
|
||||
this._messages.push(new BufferedItem(serializedMessage, this._totalMessageCount, backpressurePromiseResolver, backpressurePromiseRejector));
|
||||
}
|
||||
try {
|
||||
// If this is set it means we are reconnecting or resending
|
||||
// We don't want to send on a disconnected connection
|
||||
// And we don't want to send if resend is running since that would mean sending
|
||||
// this message twice
|
||||
if (!this._reconnectInProgress) {
|
||||
await this._connection.send(serializedMessage);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
this._disconnected();
|
||||
}
|
||||
await backpressurePromise;
|
||||
}
|
||||
_ack(ackMessage) {
|
||||
let newestAckedMessage = -1;
|
||||
// Find index of newest message being acked
|
||||
for (let index = 0; index < this._messages.length; index++) {
|
||||
const element = this._messages[index];
|
||||
if (element._id <= ackMessage.sequenceId) {
|
||||
newestAckedMessage = index;
|
||||
if ((0, Utils_1.isArrayBuffer)(element._message)) {
|
||||
this._bufferedByteCount -= element._message.byteLength;
|
||||
}
|
||||
else {
|
||||
this._bufferedByteCount -= element._message.length;
|
||||
}
|
||||
// resolve items that have already been sent and acked
|
||||
element._resolver();
|
||||
}
|
||||
else if (this._bufferedByteCount < this._bufferSize) {
|
||||
// resolve items that now fall under the buffer limit but haven't been acked
|
||||
element._resolver();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newestAckedMessage !== -1) {
|
||||
// We're removing everything including the message pointed to, so add 1
|
||||
this._messages = this._messages.slice(newestAckedMessage + 1);
|
||||
}
|
||||
}
|
||||
_shouldProcessMessage(message) {
|
||||
if (this._waitForSequenceMessage) {
|
||||
if (message.type !== IHubProtocol_1.MessageType.Sequence) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
this._waitForSequenceMessage = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No special processing for acks, pings, etc.
|
||||
if (!this._isInvocationMessage(message)) {
|
||||
return true;
|
||||
}
|
||||
const currentId = this._nextReceivingSequenceId;
|
||||
this._nextReceivingSequenceId++;
|
||||
if (currentId <= this._latestReceivedSequenceId) {
|
||||
if (currentId === this._latestReceivedSequenceId) {
|
||||
// Should only hit this if we just reconnected and the server is sending
|
||||
// Messages it has buffered, which would mean it hasn't seen an Ack for these messages
|
||||
this._ackTimer();
|
||||
}
|
||||
// Ignore, this is a duplicate message
|
||||
return false;
|
||||
}
|
||||
this._latestReceivedSequenceId = currentId;
|
||||
// Only start the timer for sending an Ack message when we have a message to ack. This also conveniently solves
|
||||
// timer throttling by not having a recursive timer, and by starting the timer via a network call (recv)
|
||||
this._ackTimer();
|
||||
return true;
|
||||
}
|
||||
_resetSequence(message) {
|
||||
if (message.sequenceId > this._nextReceivingSequenceId) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this._connection.stop(new Error("Sequence ID greater than amount of messages we've received."));
|
||||
return;
|
||||
}
|
||||
this._nextReceivingSequenceId = message.sequenceId;
|
||||
}
|
||||
_disconnected() {
|
||||
this._reconnectInProgress = true;
|
||||
this._waitForSequenceMessage = true;
|
||||
}
|
||||
async _resend() {
|
||||
const sequenceId = this._messages.length !== 0
|
||||
? this._messages[0]._id
|
||||
: this._totalMessageCount + 1;
|
||||
await this._connection.send(this._protocol.writeMessage({ type: IHubProtocol_1.MessageType.Sequence, sequenceId }));
|
||||
// Get a local variable to the _messages, just in case messages are acked while resending
|
||||
// Which would slice the _messages array (which creates a new copy)
|
||||
const messages = this._messages;
|
||||
for (const element of messages) {
|
||||
await this._connection.send(element._message);
|
||||
}
|
||||
this._reconnectInProgress = false;
|
||||
}
|
||||
_dispose(error) {
|
||||
error !== null && error !== void 0 ? error : (error = new Error("Unable to reconnect to server."));
|
||||
// Unblock backpressure if any
|
||||
for (const element of this._messages) {
|
||||
element._rejector(error);
|
||||
}
|
||||
}
|
||||
_isInvocationMessage(message) {
|
||||
// There is no way to check if something implements an interface.
|
||||
// So we individually check the messages in a switch statement.
|
||||
// To make sure we don't miss any message types we rely on the compiler
|
||||
// seeing the function returns a value and it will do the
|
||||
// exhaustive check for us on the switch statement, since we don't use 'case default'
|
||||
switch (message.type) {
|
||||
case IHubProtocol_1.MessageType.Invocation:
|
||||
case IHubProtocol_1.MessageType.StreamItem:
|
||||
case IHubProtocol_1.MessageType.Completion:
|
||||
case IHubProtocol_1.MessageType.StreamInvocation:
|
||||
case IHubProtocol_1.MessageType.CancelInvocation:
|
||||
return true;
|
||||
case IHubProtocol_1.MessageType.Close:
|
||||
case IHubProtocol_1.MessageType.Sequence:
|
||||
case IHubProtocol_1.MessageType.Ping:
|
||||
case IHubProtocol_1.MessageType.Ack:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_ackTimer() {
|
||||
if (this._ackTimerHandle === undefined) {
|
||||
this._ackTimerHandle = setTimeout(async () => {
|
||||
try {
|
||||
if (!this._reconnectInProgress) {
|
||||
await this._connection.send(this._protocol.writeMessage({ type: IHubProtocol_1.MessageType.Ack, sequenceId: this._latestReceivedSequenceId }));
|
||||
}
|
||||
// Ignore errors, that means the connection is closed and we don't care about the Ack message anymore.
|
||||
}
|
||||
catch { }
|
||||
clearTimeout(this._ackTimerHandle);
|
||||
this._ackTimerHandle = undefined;
|
||||
// 1 second delay so we don't spam Ack messages if there are many messages being received at once.
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.MessageBuffer = MessageBuffer;
|
||||
class BufferedItem {
|
||||
constructor(message, id, resolver, rejector) {
|
||||
this._message = message;
|
||||
this._id = id;
|
||||
this._resolver = resolver;
|
||||
this._rejector = rejector;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=MessageBuffer.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/MessageBuffer.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/MessageBuffer.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Polyfills.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Polyfills.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Polyfills.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Polyfills.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Polyfills.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Polyfills.js","sourceRoot":"","sources":["../../src/Polyfills.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// Not exported from index\r\n\r\n/** @private */\r\nexport type EventSourceConstructor = new(url: string, eventSourceInitDict?: EventSourceInit) => EventSource;\r\n\r\n/** @private */\r\nexport interface WebSocketConstructor {\r\n new(url: string, protocols?: string | string[], options?: any): WebSocket;\r\n readonly CLOSED: number;\r\n readonly CLOSING: number;\r\n readonly CONNECTING: number;\r\n readonly OPEN: number;\r\n}\r\n"]}
|
||||
107
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ServerSentEventsTransport.js
vendored
Normal file
107
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ServerSentEventsTransport.js
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ServerSentEventsTransport = void 0;
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const ITransport_1 = require("./ITransport");
|
||||
const Utils_1 = require("./Utils");
|
||||
/** @private */
|
||||
class ServerSentEventsTransport {
|
||||
constructor(httpClient, accessToken, logger, options) {
|
||||
this._httpClient = httpClient;
|
||||
this._accessToken = accessToken;
|
||||
this._logger = logger;
|
||||
this._options = options;
|
||||
this.onreceive = null;
|
||||
this.onclose = null;
|
||||
}
|
||||
async connect(url, transferFormat) {
|
||||
Utils_1.Arg.isRequired(url, "url");
|
||||
Utils_1.Arg.isRequired(transferFormat, "transferFormat");
|
||||
Utils_1.Arg.isIn(transferFormat, ITransport_1.TransferFormat, "transferFormat");
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(SSE transport) Connecting.");
|
||||
// set url before accessTokenFactory because this._url is only for send and we set the auth header instead of the query string for send
|
||||
this._url = url;
|
||||
if (this._accessToken) {
|
||||
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(this._accessToken)}`;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let opened = false;
|
||||
if (transferFormat !== ITransport_1.TransferFormat.Text) {
|
||||
reject(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
|
||||
return;
|
||||
}
|
||||
let eventSource;
|
||||
if (Utils_1.Platform.isBrowser || Utils_1.Platform.isWebWorker) {
|
||||
eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials });
|
||||
}
|
||||
else {
|
||||
// Non-browser passes cookies via the dictionary
|
||||
const cookies = this._httpClient.getCookieString(url);
|
||||
const headers = {};
|
||||
headers.Cookie = cookies;
|
||||
const [name, value] = (0, Utils_1.getUserAgentHeader)();
|
||||
headers[name] = value;
|
||||
eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials, headers: { ...headers, ...this._options.headers } });
|
||||
}
|
||||
try {
|
||||
eventSource.onmessage = (e) => {
|
||||
if (this.onreceive) {
|
||||
try {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(SSE transport) data received. ${(0, Utils_1.getDataDetail)(e.data, this._options.logMessageContent)}.`);
|
||||
this.onreceive(e.data);
|
||||
}
|
||||
catch (error) {
|
||||
this._close(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
// @ts-ignore: not using event on purpose
|
||||
eventSource.onerror = (e) => {
|
||||
// EventSource doesn't give any useful information about server side closes.
|
||||
if (opened) {
|
||||
this._close();
|
||||
}
|
||||
else {
|
||||
reject(new Error("EventSource failed to connect. The connection could not be found on the server,"
|
||||
+ " either the connection ID is not present on the server, or a proxy is refusing/buffering the connection."
|
||||
+ " If you have multiple servers check that sticky sessions are enabled."));
|
||||
}
|
||||
};
|
||||
eventSource.onopen = () => {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `SSE connected to ${this._url}`);
|
||||
this._eventSource = eventSource;
|
||||
opened = true;
|
||||
resolve();
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
async send(data) {
|
||||
if (!this._eventSource) {
|
||||
return Promise.reject(new Error("Cannot send until the transport is connected"));
|
||||
}
|
||||
return (0, Utils_1.sendMessage)(this._logger, "SSE", this._httpClient, this._url, data, this._options);
|
||||
}
|
||||
stop() {
|
||||
this._close();
|
||||
return Promise.resolve();
|
||||
}
|
||||
_close(e) {
|
||||
if (this._eventSource) {
|
||||
this._eventSource.close();
|
||||
this._eventSource = undefined;
|
||||
if (this.onclose) {
|
||||
this.onclose(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ServerSentEventsTransport = ServerSentEventsTransport;
|
||||
//# sourceMappingURL=ServerSentEventsTransport.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ServerSentEventsTransport.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/ServerSentEventsTransport.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Stream.js
vendored
Normal file
5
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Stream.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Stream.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Stream.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Stream.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Stream.js","sourceRoot":"","sources":["../../src/Stream.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// This is an API that is similar to Observable, but we don't want users to confuse it for that so we rename things. Someone could\r\n// easily adapt it into the Rx interface if they wanted to. Unlike in C#, we can't just implement an \"interface\" and get extension\r\n// methods for free. The methods have to actually be added to the object (there are no extension methods in JS!). We don't want to\r\n// depend on RxJS in the core library, so instead we duplicate the minimum logic needed and then users can easily adapt these into\r\n// proper RxJS observables if they want.\r\n\r\n/** Defines the expected type for a receiver of results streamed by the server.\r\n *\r\n * @typeparam T The type of the items being sent by the server.\r\n */\r\nexport interface IStreamSubscriber<T> {\r\n /** A boolean that will be set by the {@link @microsoft/signalr.IStreamResult} when the stream is closed. */\r\n closed?: boolean;\r\n /** Called by the framework when a new item is available. */\r\n next(value: T): void;\r\n /** Called by the framework when an error has occurred.\r\n *\r\n * After this method is called, no additional methods on the {@link @microsoft/signalr.IStreamSubscriber} will be called.\r\n */\r\n error(err: any): void;\r\n /** Called by the framework when the end of the stream is reached.\r\n *\r\n * After this method is called, no additional methods on the {@link @microsoft/signalr.IStreamSubscriber} will be called.\r\n */\r\n complete(): void;\r\n}\r\n\r\n/** Defines the result of a streaming hub method.\r\n *\r\n * @typeparam T The type of the items being sent by the server.\r\n */\r\nexport interface IStreamResult<T> {\r\n /** Attaches a {@link @microsoft/signalr.IStreamSubscriber}, which will be invoked when new items are available from the stream.\r\n *\r\n * @param {IStreamSubscriber<T>} observer The subscriber to attach.\r\n * @returns {ISubscription<T>} A subscription that can be disposed to terminate the stream and stop calling methods on the {@link @microsoft/signalr.IStreamSubscriber}.\r\n */\r\n subscribe(subscriber: IStreamSubscriber<T>): ISubscription<T>;\r\n}\r\n\r\n/** An interface that allows an {@link @microsoft/signalr.IStreamSubscriber} to be disconnected from a stream.\r\n *\r\n * @typeparam T The type of the items being sent by the server.\r\n */\r\n// @ts-ignore: We can't remove this, it's a breaking change, but it's not used.\r\nexport interface ISubscription<T> {\r\n /** Disconnects the {@link @microsoft/signalr.IStreamSubscriber} associated with this subscription from the stream. */\r\n dispose(): void;\r\n}\r\n"]}
|
||||
37
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Subject.js
vendored
Normal file
37
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Subject.js
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Subject = void 0;
|
||||
const Utils_1 = require("./Utils");
|
||||
/** Stream implementation to stream items to the server. */
|
||||
class Subject {
|
||||
constructor() {
|
||||
this.observers = [];
|
||||
}
|
||||
next(item) {
|
||||
for (const observer of this.observers) {
|
||||
observer.next(item);
|
||||
}
|
||||
}
|
||||
error(err) {
|
||||
for (const observer of this.observers) {
|
||||
if (observer.error) {
|
||||
observer.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
complete() {
|
||||
for (const observer of this.observers) {
|
||||
if (observer.complete) {
|
||||
observer.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
subscribe(observer) {
|
||||
this.observers.push(observer);
|
||||
return new Utils_1.SubjectSubscription(this, observer);
|
||||
}
|
||||
}
|
||||
exports.Subject = Subject;
|
||||
//# sourceMappingURL=Subject.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Subject.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Subject.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Subject.js","sourceRoot":"","sources":["../../src/Subject.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAGvE,mCAA8C;AAE9C,2DAA2D;AAC3D,MAAa,OAAO;IAOhB;QACI,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC;IAEM,IAAI,CAAC,IAAO;QACf,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACnC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACvB;IACL,CAAC;IAEM,KAAK,CAAC,GAAQ;QACjB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACnC,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAChB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACvB;SACJ;IACL,CAAC;IAEM,QAAQ;QACX,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACnC,IAAI,QAAQ,CAAC,QAAQ,EAAE;gBACnB,QAAQ,CAAC,QAAQ,EAAE,CAAC;aACvB;SACJ;IACL,CAAC;IAEM,SAAS,CAAC,QAA8B;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,IAAI,2BAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;CACJ;AArCD,0BAqCC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { IStreamResult, IStreamSubscriber, ISubscription } from \"./Stream\";\r\nimport { SubjectSubscription } from \"./Utils\";\r\n\r\n/** Stream implementation to stream items to the server. */\r\nexport class Subject<T> implements IStreamResult<T> {\r\n /** @internal */\r\n public observers: IStreamSubscriber<T>[];\r\n\r\n /** @internal */\r\n public cancelCallback?: () => Promise<void>;\r\n\r\n constructor() {\r\n this.observers = [];\r\n }\r\n\r\n public next(item: T): void {\r\n for (const observer of this.observers) {\r\n observer.next(item);\r\n }\r\n }\r\n\r\n public error(err: any): void {\r\n for (const observer of this.observers) {\r\n if (observer.error) {\r\n observer.error(err);\r\n }\r\n }\r\n }\r\n\r\n public complete(): void {\r\n for (const observer of this.observers) {\r\n if (observer.complete) {\r\n observer.complete();\r\n }\r\n }\r\n }\r\n\r\n public subscribe(observer: IStreamSubscriber<T>): ISubscription<T> {\r\n this.observers.push(observer);\r\n return new SubjectSubscription(this, observer);\r\n }\r\n}\r\n"]}
|
||||
24
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/TextMessageFormat.js
vendored
Normal file
24
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/TextMessageFormat.js
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TextMessageFormat = void 0;
|
||||
// Not exported from index
|
||||
/** @private */
|
||||
class TextMessageFormat {
|
||||
static write(output) {
|
||||
return `${output}${TextMessageFormat.RecordSeparator}`;
|
||||
}
|
||||
static parse(input) {
|
||||
if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
|
||||
throw new Error("Message is incomplete.");
|
||||
}
|
||||
const messages = input.split(TextMessageFormat.RecordSeparator);
|
||||
messages.pop();
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
exports.TextMessageFormat = TextMessageFormat;
|
||||
TextMessageFormat.RecordSeparatorCode = 0x1e;
|
||||
TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
|
||||
//# sourceMappingURL=TextMessageFormat.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/TextMessageFormat.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/TextMessageFormat.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"TextMessageFormat.js","sourceRoot":"","sources":["../../src/TextMessageFormat.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAEvE,0BAA0B;AAC1B,eAAe;AACf,MAAa,iBAAiB;IAInB,MAAM,CAAC,KAAK,CAAC,MAAc;QAC9B,OAAO,GAAG,MAAM,GAAG,iBAAiB,CAAC,eAAe,EAAE,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,KAAa;QAC7B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,iBAAiB,CAAC,eAAe,EAAE;YAC/D,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC7C;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;QAChE,QAAQ,CAAC,GAAG,EAAE,CAAC;QACf,OAAO,QAAQ,CAAC;IACpB,CAAC;;AAhBL,8CAiBC;AAhBiB,qCAAmB,GAAG,IAAI,CAAC;AAC3B,iCAAe,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// Not exported from index\r\n/** @private */\r\nexport class TextMessageFormat {\r\n public static RecordSeparatorCode = 0x1e;\r\n public static RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);\r\n\r\n public static write(output: string): string {\r\n return `${output}${TextMessageFormat.RecordSeparator}`;\r\n }\r\n\r\n public static parse(input: string): string[] {\r\n if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {\r\n throw new Error(\"Message is incomplete.\");\r\n }\r\n\r\n const messages = input.split(TextMessageFormat.RecordSeparator);\r\n messages.pop();\r\n return messages;\r\n }\r\n}\r\n"]}
|
||||
264
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Utils.js
vendored
Normal file
264
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Utils.js
vendored
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getGlobalThis = exports.getErrorString = exports.constructUserAgent = exports.getUserAgentHeader = exports.ConsoleLogger = exports.SubjectSubscription = exports.createLogger = exports.sendMessage = exports.isArrayBuffer = exports.formatArrayBuffer = exports.getDataDetail = exports.Platform = exports.Arg = exports.VERSION = void 0;
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const Loggers_1 = require("./Loggers");
|
||||
// Version token that will be replaced by the prepack command
|
||||
/** The version of the SignalR client. */
|
||||
exports.VERSION = "8.0.0";
|
||||
/** @private */
|
||||
class Arg {
|
||||
static isRequired(val, name) {
|
||||
if (val === null || val === undefined) {
|
||||
throw new Error(`The '${name}' argument is required.`);
|
||||
}
|
||||
}
|
||||
static isNotEmpty(val, name) {
|
||||
if (!val || val.match(/^\s*$/)) {
|
||||
throw new Error(`The '${name}' argument should not be empty.`);
|
||||
}
|
||||
}
|
||||
static isIn(val, values, name) {
|
||||
// TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.
|
||||
if (!(val in values)) {
|
||||
throw new Error(`Unknown ${name} value: ${val}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Arg = Arg;
|
||||
/** @private */
|
||||
class Platform {
|
||||
// react-native has a window but no document so we should check both
|
||||
static get isBrowser() {
|
||||
return !Platform.isNode && typeof window === "object" && typeof window.document === "object";
|
||||
}
|
||||
// WebWorkers don't have a window object so the isBrowser check would fail
|
||||
static get isWebWorker() {
|
||||
return !Platform.isNode && typeof self === "object" && "importScripts" in self;
|
||||
}
|
||||
// react-native has a window but no document
|
||||
static get isReactNative() {
|
||||
return !Platform.isNode && typeof window === "object" && typeof window.document === "undefined";
|
||||
}
|
||||
// Node apps shouldn't have a window object, but WebWorkers don't either
|
||||
// so we need to check for both WebWorker and window
|
||||
static get isNode() {
|
||||
return typeof process !== "undefined" && process.release && process.release.name === "node";
|
||||
}
|
||||
}
|
||||
exports.Platform = Platform;
|
||||
/** @private */
|
||||
function getDataDetail(data, includeContent) {
|
||||
let detail = "";
|
||||
if (isArrayBuffer(data)) {
|
||||
detail = `Binary data of length ${data.byteLength}`;
|
||||
if (includeContent) {
|
||||
detail += `. Content: '${formatArrayBuffer(data)}'`;
|
||||
}
|
||||
}
|
||||
else if (typeof data === "string") {
|
||||
detail = `String data of length ${data.length}`;
|
||||
if (includeContent) {
|
||||
detail += `. Content: '${data}'`;
|
||||
}
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
exports.getDataDetail = getDataDetail;
|
||||
/** @private */
|
||||
function formatArrayBuffer(data) {
|
||||
const view = new Uint8Array(data);
|
||||
// Uint8Array.map only supports returning another Uint8Array?
|
||||
let str = "";
|
||||
view.forEach((num) => {
|
||||
const pad = num < 16 ? "0" : "";
|
||||
str += `0x${pad}${num.toString(16)} `;
|
||||
});
|
||||
// Trim of trailing space.
|
||||
return str.substr(0, str.length - 1);
|
||||
}
|
||||
exports.formatArrayBuffer = formatArrayBuffer;
|
||||
// Also in signalr-protocol-msgpack/Utils.ts
|
||||
/** @private */
|
||||
function isArrayBuffer(val) {
|
||||
return val && typeof ArrayBuffer !== "undefined" &&
|
||||
(val instanceof ArrayBuffer ||
|
||||
// Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
|
||||
(val.constructor && val.constructor.name === "ArrayBuffer"));
|
||||
}
|
||||
exports.isArrayBuffer = isArrayBuffer;
|
||||
/** @private */
|
||||
async function sendMessage(logger, transportName, httpClient, url, content, options) {
|
||||
const headers = {};
|
||||
const [name, value] = getUserAgentHeader();
|
||||
headers[name] = value;
|
||||
logger.log(ILogger_1.LogLevel.Trace, `(${transportName} transport) sending data. ${getDataDetail(content, options.logMessageContent)}.`);
|
||||
const responseType = isArrayBuffer(content) ? "arraybuffer" : "text";
|
||||
const response = await httpClient.post(url, {
|
||||
content,
|
||||
headers: { ...headers, ...options.headers },
|
||||
responseType,
|
||||
timeout: options.timeout,
|
||||
withCredentials: options.withCredentials,
|
||||
});
|
||||
logger.log(ILogger_1.LogLevel.Trace, `(${transportName} transport) request complete. Response status: ${response.statusCode}.`);
|
||||
}
|
||||
exports.sendMessage = sendMessage;
|
||||
/** @private */
|
||||
function createLogger(logger) {
|
||||
if (logger === undefined) {
|
||||
return new ConsoleLogger(ILogger_1.LogLevel.Information);
|
||||
}
|
||||
if (logger === null) {
|
||||
return Loggers_1.NullLogger.instance;
|
||||
}
|
||||
if (logger.log !== undefined) {
|
||||
return logger;
|
||||
}
|
||||
return new ConsoleLogger(logger);
|
||||
}
|
||||
exports.createLogger = createLogger;
|
||||
/** @private */
|
||||
class SubjectSubscription {
|
||||
constructor(subject, observer) {
|
||||
this._subject = subject;
|
||||
this._observer = observer;
|
||||
}
|
||||
dispose() {
|
||||
const index = this._subject.observers.indexOf(this._observer);
|
||||
if (index > -1) {
|
||||
this._subject.observers.splice(index, 1);
|
||||
}
|
||||
if (this._subject.observers.length === 0 && this._subject.cancelCallback) {
|
||||
this._subject.cancelCallback().catch((_) => { });
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SubjectSubscription = SubjectSubscription;
|
||||
/** @private */
|
||||
class ConsoleLogger {
|
||||
constructor(minimumLogLevel) {
|
||||
this._minLevel = minimumLogLevel;
|
||||
this.out = console;
|
||||
}
|
||||
log(logLevel, message) {
|
||||
if (logLevel >= this._minLevel) {
|
||||
const msg = `[${new Date().toISOString()}] ${ILogger_1.LogLevel[logLevel]}: ${message}`;
|
||||
switch (logLevel) {
|
||||
case ILogger_1.LogLevel.Critical:
|
||||
case ILogger_1.LogLevel.Error:
|
||||
this.out.error(msg);
|
||||
break;
|
||||
case ILogger_1.LogLevel.Warning:
|
||||
this.out.warn(msg);
|
||||
break;
|
||||
case ILogger_1.LogLevel.Information:
|
||||
this.out.info(msg);
|
||||
break;
|
||||
default:
|
||||
// console.debug only goes to attached debuggers in Node, so we use console.log for Trace and Debug
|
||||
this.out.log(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ConsoleLogger = ConsoleLogger;
|
||||
/** @private */
|
||||
function getUserAgentHeader() {
|
||||
let userAgentHeaderName = "X-SignalR-User-Agent";
|
||||
if (Platform.isNode) {
|
||||
userAgentHeaderName = "User-Agent";
|
||||
}
|
||||
return [userAgentHeaderName, constructUserAgent(exports.VERSION, getOsName(), getRuntime(), getRuntimeVersion())];
|
||||
}
|
||||
exports.getUserAgentHeader = getUserAgentHeader;
|
||||
/** @private */
|
||||
function constructUserAgent(version, os, runtime, runtimeVersion) {
|
||||
// Microsoft SignalR/[Version] ([Detailed Version]; [Operating System]; [Runtime]; [Runtime Version])
|
||||
let userAgent = "Microsoft SignalR/";
|
||||
const majorAndMinor = version.split(".");
|
||||
userAgent += `${majorAndMinor[0]}.${majorAndMinor[1]}`;
|
||||
userAgent += ` (${version}; `;
|
||||
if (os && os !== "") {
|
||||
userAgent += `${os}; `;
|
||||
}
|
||||
else {
|
||||
userAgent += "Unknown OS; ";
|
||||
}
|
||||
userAgent += `${runtime}`;
|
||||
if (runtimeVersion) {
|
||||
userAgent += `; ${runtimeVersion}`;
|
||||
}
|
||||
else {
|
||||
userAgent += "; Unknown Runtime Version";
|
||||
}
|
||||
userAgent += ")";
|
||||
return userAgent;
|
||||
}
|
||||
exports.constructUserAgent = constructUserAgent;
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/*#__PURE__*/ function getOsName() {
|
||||
if (Platform.isNode) {
|
||||
switch (process.platform) {
|
||||
case "win32":
|
||||
return "Windows NT";
|
||||
case "darwin":
|
||||
return "macOS";
|
||||
case "linux":
|
||||
return "Linux";
|
||||
default:
|
||||
return process.platform;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/*#__PURE__*/ function getRuntimeVersion() {
|
||||
if (Platform.isNode) {
|
||||
return process.versions.node;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getRuntime() {
|
||||
if (Platform.isNode) {
|
||||
return "NodeJS";
|
||||
}
|
||||
else {
|
||||
return "Browser";
|
||||
}
|
||||
}
|
||||
/** @private */
|
||||
function getErrorString(e) {
|
||||
if (e.stack) {
|
||||
return e.stack;
|
||||
}
|
||||
else if (e.message) {
|
||||
return e.message;
|
||||
}
|
||||
return `${e}`;
|
||||
}
|
||||
exports.getErrorString = getErrorString;
|
||||
/** @private */
|
||||
function getGlobalThis() {
|
||||
// globalThis is semi-new and not available in Node until v12
|
||||
if (typeof globalThis !== "undefined") {
|
||||
return globalThis;
|
||||
}
|
||||
if (typeof self !== "undefined") {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== "undefined") {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== "undefined") {
|
||||
return global;
|
||||
}
|
||||
throw new Error("could not find global");
|
||||
}
|
||||
exports.getGlobalThis = getGlobalThis;
|
||||
//# sourceMappingURL=Utils.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Utils.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/Utils.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
159
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/WebSocketTransport.js
vendored
Normal file
159
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/WebSocketTransport.js
vendored
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WebSocketTransport = void 0;
|
||||
const HeaderNames_1 = require("./HeaderNames");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const ITransport_1 = require("./ITransport");
|
||||
const Utils_1 = require("./Utils");
|
||||
/** @private */
|
||||
class WebSocketTransport {
|
||||
constructor(httpClient, accessTokenFactory, logger, logMessageContent, webSocketConstructor, headers) {
|
||||
this._logger = logger;
|
||||
this._accessTokenFactory = accessTokenFactory;
|
||||
this._logMessageContent = logMessageContent;
|
||||
this._webSocketConstructor = webSocketConstructor;
|
||||
this._httpClient = httpClient;
|
||||
this.onreceive = null;
|
||||
this.onclose = null;
|
||||
this._headers = headers;
|
||||
}
|
||||
async connect(url, transferFormat) {
|
||||
Utils_1.Arg.isRequired(url, "url");
|
||||
Utils_1.Arg.isRequired(transferFormat, "transferFormat");
|
||||
Utils_1.Arg.isIn(transferFormat, ITransport_1.TransferFormat, "transferFormat");
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(WebSockets transport) Connecting.");
|
||||
let token;
|
||||
if (this._accessTokenFactory) {
|
||||
token = await this._accessTokenFactory();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
url = url.replace(/^http/, "ws");
|
||||
let webSocket;
|
||||
const cookies = this._httpClient.getCookieString(url);
|
||||
let opened = false;
|
||||
if (Utils_1.Platform.isNode || Utils_1.Platform.isReactNative) {
|
||||
const headers = {};
|
||||
const [name, value] = (0, Utils_1.getUserAgentHeader)();
|
||||
headers[name] = value;
|
||||
if (token) {
|
||||
headers[HeaderNames_1.HeaderNames.Authorization] = `Bearer ${token}`;
|
||||
}
|
||||
if (cookies) {
|
||||
headers[HeaderNames_1.HeaderNames.Cookie] = cookies;
|
||||
}
|
||||
// Only pass headers when in non-browser environments
|
||||
webSocket = new this._webSocketConstructor(url, undefined, {
|
||||
headers: { ...headers, ...this._headers },
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (token) {
|
||||
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`;
|
||||
}
|
||||
}
|
||||
if (!webSocket) {
|
||||
// Chrome is not happy with passing 'undefined' as protocol
|
||||
webSocket = new this._webSocketConstructor(url);
|
||||
}
|
||||
if (transferFormat === ITransport_1.TransferFormat.Binary) {
|
||||
webSocket.binaryType = "arraybuffer";
|
||||
}
|
||||
webSocket.onopen = (_event) => {
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `WebSocket connected to ${url}.`);
|
||||
this._webSocket = webSocket;
|
||||
opened = true;
|
||||
resolve();
|
||||
};
|
||||
webSocket.onerror = (event) => {
|
||||
let error = null;
|
||||
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
||||
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
||||
error = event.error;
|
||||
}
|
||||
else {
|
||||
error = "There was an error with the transport";
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Information, `(WebSockets transport) ${error}.`);
|
||||
};
|
||||
webSocket.onmessage = (message) => {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(WebSockets transport) data received. ${(0, Utils_1.getDataDetail)(message.data, this._logMessageContent)}.`);
|
||||
if (this.onreceive) {
|
||||
try {
|
||||
this.onreceive(message.data);
|
||||
}
|
||||
catch (error) {
|
||||
this._close(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
webSocket.onclose = (event) => {
|
||||
// Don't call close handler if connection was never established
|
||||
// We'll reject the connect call instead
|
||||
if (opened) {
|
||||
this._close(event);
|
||||
}
|
||||
else {
|
||||
let error = null;
|
||||
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
||||
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
||||
error = event.error;
|
||||
}
|
||||
else {
|
||||
error = "WebSocket failed to connect. The connection could not be found on the server,"
|
||||
+ " either the endpoint may not be a SignalR endpoint,"
|
||||
+ " the connection ID is not present on the server, or there is a proxy blocking WebSockets."
|
||||
+ " If you have multiple servers check that sticky sessions are enabled.";
|
||||
}
|
||||
reject(new Error(error));
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
send(data) {
|
||||
if (this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN) {
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, `(WebSockets transport) sending data. ${(0, Utils_1.getDataDetail)(data, this._logMessageContent)}.`);
|
||||
this._webSocket.send(data);
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject("WebSocket is not in the OPEN state");
|
||||
}
|
||||
stop() {
|
||||
if (this._webSocket) {
|
||||
// Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning
|
||||
// This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects
|
||||
this._close(undefined);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
_close(event) {
|
||||
// webSocket will be null if the transport did not start successfully
|
||||
if (this._webSocket) {
|
||||
// Clear websocket handlers because we are considering the socket closed now
|
||||
this._webSocket.onclose = () => { };
|
||||
this._webSocket.onmessage = () => { };
|
||||
this._webSocket.onerror = () => { };
|
||||
this._webSocket.close();
|
||||
this._webSocket = undefined;
|
||||
}
|
||||
this._logger.log(ILogger_1.LogLevel.Trace, "(WebSockets transport) socket closed.");
|
||||
if (this.onclose) {
|
||||
if (this._isCloseEvent(event) && (event.wasClean === false || event.code !== 1000)) {
|
||||
this.onclose(new Error(`WebSocket closed with status code: ${event.code} (${event.reason || "no reason given"}).`));
|
||||
}
|
||||
else if (event instanceof Error) {
|
||||
this.onclose(event);
|
||||
}
|
||||
else {
|
||||
this.onclose();
|
||||
}
|
||||
}
|
||||
}
|
||||
_isCloseEvent(event) {
|
||||
return event && typeof event.wasClean === "boolean" && typeof event.code === "number";
|
||||
}
|
||||
}
|
||||
exports.WebSocketTransport = WebSocketTransport;
|
||||
//# sourceMappingURL=WebSocketTransport.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/WebSocketTransport.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/WebSocketTransport.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
87
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/XhrHttpClient.js
vendored
Normal file
87
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/XhrHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.XhrHttpClient = void 0;
|
||||
const Errors_1 = require("./Errors");
|
||||
const HttpClient_1 = require("./HttpClient");
|
||||
const ILogger_1 = require("./ILogger");
|
||||
const Utils_1 = require("./Utils");
|
||||
class XhrHttpClient extends HttpClient_1.HttpClient {
|
||||
constructor(logger) {
|
||||
super();
|
||||
this._logger = logger;
|
||||
}
|
||||
/** @inheritDoc */
|
||||
send(request) {
|
||||
// Check that abort was not signaled before calling send
|
||||
if (request.abortSignal && request.abortSignal.aborted) {
|
||||
return Promise.reject(new Errors_1.AbortError());
|
||||
}
|
||||
if (!request.method) {
|
||||
return Promise.reject(new Error("No method defined."));
|
||||
}
|
||||
if (!request.url) {
|
||||
return Promise.reject(new Error("No url defined."));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open(request.method, request.url, true);
|
||||
xhr.withCredentials = request.withCredentials === undefined ? true : request.withCredentials;
|
||||
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||||
if (request.content === "") {
|
||||
request.content = undefined;
|
||||
}
|
||||
if (request.content) {
|
||||
// Explicitly setting the Content-Type header for React Native on Android platform.
|
||||
if ((0, Utils_1.isArrayBuffer)(request.content)) {
|
||||
xhr.setRequestHeader("Content-Type", "application/octet-stream");
|
||||
}
|
||||
else {
|
||||
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
|
||||
}
|
||||
}
|
||||
const headers = request.headers;
|
||||
if (headers) {
|
||||
Object.keys(headers)
|
||||
.forEach((header) => {
|
||||
xhr.setRequestHeader(header, headers[header]);
|
||||
});
|
||||
}
|
||||
if (request.responseType) {
|
||||
xhr.responseType = request.responseType;
|
||||
}
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = () => {
|
||||
xhr.abort();
|
||||
reject(new Errors_1.AbortError());
|
||||
};
|
||||
}
|
||||
if (request.timeout) {
|
||||
xhr.timeout = request.timeout;
|
||||
}
|
||||
xhr.onload = () => {
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = null;
|
||||
}
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
resolve(new HttpClient_1.HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
||||
}
|
||||
else {
|
||||
reject(new Errors_1.HttpError(xhr.response || xhr.responseText || xhr.statusText, xhr.status));
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Error from HTTP request. ${xhr.status}: ${xhr.statusText}.`);
|
||||
reject(new Errors_1.HttpError(xhr.statusText, xhr.status));
|
||||
};
|
||||
xhr.ontimeout = () => {
|
||||
this._logger.log(ILogger_1.LogLevel.Warning, `Timeout from HTTP request.`);
|
||||
reject(new Errors_1.TimeoutError());
|
||||
};
|
||||
xhr.send(request.content);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.XhrHttpClient = XhrHttpClient;
|
||||
//# sourceMappingURL=XhrHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/XhrHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/XhrHttpClient.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
44
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/browser-index.js
vendored
Normal file
44
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/browser-index.js
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
|
||||
// Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
|
||||
// that exist on Uint8Array with the same name, and JavaScript is magic.
|
||||
// We make them 'writable' because the Buffer polyfill messes with it as well.
|
||||
if (!Uint8Array.prototype.indexOf) {
|
||||
Object.defineProperty(Uint8Array.prototype, "indexOf", {
|
||||
value: Array.prototype.indexOf,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
if (!Uint8Array.prototype.slice) {
|
||||
Object.defineProperty(Uint8Array.prototype, "slice", {
|
||||
// wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
|
||||
// eslint-disable-next-line object-shorthand
|
||||
value: function (start, end) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
if (!Uint8Array.prototype.forEach) {
|
||||
Object.defineProperty(Uint8Array.prototype, "forEach", {
|
||||
value: Array.prototype.forEach,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
__exportStar(require("./index"), exports);
|
||||
//# sourceMappingURL=browser-index.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/browser-index.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/browser-index.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"browser-index.js","sourceRoot":"","sources":["../../src/browser-index.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;;;;;;;;;;;;;;AAEvE,qHAAqH;AAErH,uIAAuI;AACvI,wEAAwE;AACxE,8EAA8E;AAC9E,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE;IAC/B,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE;QACnD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO;QAC9B,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC;CACN;AACD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE;IAC7B,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE;QACjD,wEAAwE;QACxE,4CAA4C;QAC5C,KAAK,EAAE,UAAS,KAAc,EAAE,GAAY,IAAI,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACtH,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC;CACN;AACD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE;IAC/B,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE;QACnD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO;QAC9B,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC;CACN;AAED,0CAAwB","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.\r\n\r\n// Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties\r\n// that exist on Uint8Array with the same name, and JavaScript is magic.\r\n// We make them 'writable' because the Buffer polyfill messes with it as well.\r\nif (!Uint8Array.prototype.indexOf) {\r\n Object.defineProperty(Uint8Array.prototype, \"indexOf\", {\r\n value: Array.prototype.indexOf,\r\n writable: true,\r\n });\r\n}\r\nif (!Uint8Array.prototype.slice) {\r\n Object.defineProperty(Uint8Array.prototype, \"slice\", {\r\n // wrap the slice in Uint8Array so it looks like a Uint8Array.slice call\r\n // eslint-disable-next-line object-shorthand\r\n value: function(start?: number, end?: number) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },\r\n writable: true,\r\n });\r\n}\r\nif (!Uint8Array.prototype.forEach) {\r\n Object.defineProperty(Uint8Array.prototype, \"forEach\", {\r\n value: Array.prototype.forEach,\r\n writable: true,\r\n });\r\n}\r\n\r\nexport * from \"./index\";\r\n"]}
|
||||
35
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/index.js
vendored
Normal file
35
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/index.js
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VERSION = exports.Subject = exports.JsonHubProtocol = exports.NullLogger = exports.TransferFormat = exports.HttpTransportType = exports.LogLevel = exports.MessageType = exports.HubConnectionBuilder = exports.HubConnectionState = exports.HubConnection = exports.DefaultHttpClient = exports.HttpResponse = exports.HttpClient = exports.TimeoutError = exports.HttpError = exports.AbortError = void 0;
|
||||
var Errors_1 = require("./Errors");
|
||||
Object.defineProperty(exports, "AbortError", { enumerable: true, get: function () { return Errors_1.AbortError; } });
|
||||
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return Errors_1.HttpError; } });
|
||||
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return Errors_1.TimeoutError; } });
|
||||
var HttpClient_1 = require("./HttpClient");
|
||||
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return HttpClient_1.HttpClient; } });
|
||||
Object.defineProperty(exports, "HttpResponse", { enumerable: true, get: function () { return HttpClient_1.HttpResponse; } });
|
||||
var DefaultHttpClient_1 = require("./DefaultHttpClient");
|
||||
Object.defineProperty(exports, "DefaultHttpClient", { enumerable: true, get: function () { return DefaultHttpClient_1.DefaultHttpClient; } });
|
||||
var HubConnection_1 = require("./HubConnection");
|
||||
Object.defineProperty(exports, "HubConnection", { enumerable: true, get: function () { return HubConnection_1.HubConnection; } });
|
||||
Object.defineProperty(exports, "HubConnectionState", { enumerable: true, get: function () { return HubConnection_1.HubConnectionState; } });
|
||||
var HubConnectionBuilder_1 = require("./HubConnectionBuilder");
|
||||
Object.defineProperty(exports, "HubConnectionBuilder", { enumerable: true, get: function () { return HubConnectionBuilder_1.HubConnectionBuilder; } });
|
||||
var IHubProtocol_1 = require("./IHubProtocol");
|
||||
Object.defineProperty(exports, "MessageType", { enumerable: true, get: function () { return IHubProtocol_1.MessageType; } });
|
||||
var ILogger_1 = require("./ILogger");
|
||||
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return ILogger_1.LogLevel; } });
|
||||
var ITransport_1 = require("./ITransport");
|
||||
Object.defineProperty(exports, "HttpTransportType", { enumerable: true, get: function () { return ITransport_1.HttpTransportType; } });
|
||||
Object.defineProperty(exports, "TransferFormat", { enumerable: true, get: function () { return ITransport_1.TransferFormat; } });
|
||||
var Loggers_1 = require("./Loggers");
|
||||
Object.defineProperty(exports, "NullLogger", { enumerable: true, get: function () { return Loggers_1.NullLogger; } });
|
||||
var JsonHubProtocol_1 = require("./JsonHubProtocol");
|
||||
Object.defineProperty(exports, "JsonHubProtocol", { enumerable: true, get: function () { return JsonHubProtocol_1.JsonHubProtocol; } });
|
||||
var Subject_1 = require("./Subject");
|
||||
Object.defineProperty(exports, "Subject", { enumerable: true, get: function () { return Subject_1.Subject; } });
|
||||
var Utils_1 = require("./Utils");
|
||||
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return Utils_1.VERSION; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/index.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/cjs/index.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,uEAAuE;;;AAIvE,mCAA+D;AAAtD,oGAAA,UAAU,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,sGAAA,YAAY,OAAA;AAC5C,2CAAqE;AAA5D,wGAAA,UAAU,OAAA;AAAe,0GAAA,YAAY,OAAA;AAC9C,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAG1B,iDAAoE;AAA3D,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAC1C,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,+CAE6F;AAFvD,2GAAA,WAAW,OAAA;AAGjD,qCAA8C;AAA5B,mGAAA,QAAQ,OAAA;AAC1B,2CAA6E;AAApE,+GAAA,iBAAiB,OAAA;AAAE,4GAAA,cAAc,OAAA;AAE1C,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AACnB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,iCAAkC;AAAzB,gGAAA,OAAO,OAAA","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// Everything that users need to access must be exported here. Including interfaces.\r\nexport { AbortSignal } from \"./AbortController\";\r\nexport { AbortError, HttpError, TimeoutError } from \"./Errors\";\r\nexport { HttpClient, HttpRequest, HttpResponse } from \"./HttpClient\";\r\nexport { DefaultHttpClient } from \"./DefaultHttpClient\";\r\nexport { IHttpConnectionOptions } from \"./IHttpConnectionOptions\";\r\nexport { IStatefulReconnectOptions } from \"./IStatefulReconnectOptions\";\r\nexport { HubConnection, HubConnectionState } from \"./HubConnection\";\r\nexport { HubConnectionBuilder } from \"./HubConnectionBuilder\";\r\nexport { AckMessage, SequenceMessage, MessageType, MessageHeaders, HubMessage, HubMessageBase,\r\n HubInvocationMessage, InvocationMessage, StreamInvocationMessage, StreamItemMessage, CompletionMessage,\r\n PingMessage, CloseMessage, CancelInvocationMessage, IHubProtocol } from \"./IHubProtocol\";\r\nexport { ILogger, LogLevel } from \"./ILogger\";\r\nexport { HttpTransportType, TransferFormat, ITransport } from \"./ITransport\";\r\nexport { IStreamSubscriber, IStreamResult, ISubscription } from \"./Stream\";\r\nexport { NullLogger } from \"./Loggers\";\r\nexport { JsonHubProtocol } from \"./JsonHubProtocol\";\r\nexport { Subject } from \"./Subject\";\r\nexport { IRetryPolicy, RetryContext } from \"./IRetryPolicy\";\r\nexport { VERSION } from \"./Utils\";\r\n"]}
|
||||
15
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.d.ts
vendored
Normal file
15
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.d.ts
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/** @private */
|
||||
export declare class AbortController implements AbortSignal {
|
||||
private _isAborted;
|
||||
onabort: (() => void) | null;
|
||||
abort(): void;
|
||||
get signal(): AbortSignal;
|
||||
get aborted(): boolean;
|
||||
}
|
||||
/** Represents a signal that can be monitored to determine if a request has been aborted. */
|
||||
export interface AbortSignal {
|
||||
/** Indicates if the request has been aborted. */
|
||||
aborted: boolean;
|
||||
/** Set this to a handler that will be invoked when the request is aborted. */
|
||||
onabort: (() => void) | null;
|
||||
}
|
||||
28
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.js
vendored
Normal file
28
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.js
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
||||
// We don't actually ever use the API being polyfilled, we always use the polyfill because
|
||||
// it's a very new API right now.
|
||||
// Not exported from index.
|
||||
/** @private */
|
||||
export class AbortController {
|
||||
constructor() {
|
||||
this._isAborted = false;
|
||||
this.onabort = null;
|
||||
}
|
||||
abort() {
|
||||
if (!this._isAborted) {
|
||||
this._isAborted = true;
|
||||
if (this.onabort) {
|
||||
this.onabort();
|
||||
}
|
||||
}
|
||||
}
|
||||
get signal() {
|
||||
return this;
|
||||
}
|
||||
get aborted() {
|
||||
return this._isAborted;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=AbortController.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AbortController.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AbortController.js","sourceRoot":"","sources":["../../src/AbortController.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAEvE,qFAAqF;AACrF,0FAA0F;AAC1F,iCAAiC;AAEjC,2BAA2B;AAC3B,eAAe;AACf,MAAM,OAAO,eAAe;IAA5B;QACY,eAAU,GAAY,KAAK,CAAC;QAC7B,YAAO,GAAwB,IAAI,CAAC;IAkB/C,CAAC;IAhBU,KAAK;QACR,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,IAAI,CAAC,OAAO,EAAE;gBACd,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;SACJ;IACL,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController\r\n// We don't actually ever use the API being polyfilled, we always use the polyfill because\r\n// it's a very new API right now.\r\n\r\n// Not exported from index.\r\n/** @private */\r\nexport class AbortController implements AbortSignal {\r\n private _isAborted: boolean = false;\r\n public onabort: (() => void) | null = null;\r\n\r\n public abort(): void {\r\n if (!this._isAborted) {\r\n this._isAborted = true;\r\n if (this.onabort) {\r\n this.onabort();\r\n }\r\n }\r\n }\r\n\r\n get signal(): AbortSignal {\r\n return this;\r\n }\r\n\r\n get aborted(): boolean {\r\n return this._isAborted;\r\n }\r\n}\r\n\r\n/** Represents a signal that can be monitored to determine if a request has been aborted. */\r\nexport interface AbortSignal {\r\n /** Indicates if the request has been aborted. */\r\n aborted: boolean;\r\n /** Set this to a handler that will be invoked when the request is aborted. */\r\n onabort: (() => void) | null;\r\n}\r\n"]}
|
||||
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.d.ts
vendored
Normal file
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { HttpClient, HttpRequest, HttpResponse } from "./HttpClient";
|
||||
/** @private */
|
||||
export declare class AccessTokenHttpClient extends HttpClient {
|
||||
private _innerClient;
|
||||
_accessToken: string | undefined;
|
||||
_accessTokenFactory: (() => string | Promise<string>) | undefined;
|
||||
constructor(innerClient: HttpClient, accessTokenFactory: (() => string | Promise<string>) | undefined);
|
||||
send(request: HttpRequest): Promise<HttpResponse>;
|
||||
private _setAuthorizationHeader;
|
||||
getCookieString(url: string): string;
|
||||
}
|
||||
46
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.js
vendored
Normal file
46
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
import { HeaderNames } from "./HeaderNames";
|
||||
import { HttpClient } from "./HttpClient";
|
||||
/** @private */
|
||||
export class AccessTokenHttpClient extends HttpClient {
|
||||
constructor(innerClient, accessTokenFactory) {
|
||||
super();
|
||||
this._innerClient = innerClient;
|
||||
this._accessTokenFactory = accessTokenFactory;
|
||||
}
|
||||
async send(request) {
|
||||
let allowRetry = true;
|
||||
if (this._accessTokenFactory && (!this._accessToken || (request.url && request.url.indexOf("/negotiate?") > 0))) {
|
||||
// don't retry if the request is a negotiate or if we just got a potentially new token from the access token factory
|
||||
allowRetry = false;
|
||||
this._accessToken = await this._accessTokenFactory();
|
||||
}
|
||||
this._setAuthorizationHeader(request);
|
||||
const response = await this._innerClient.send(request);
|
||||
if (allowRetry && response.statusCode === 401 && this._accessTokenFactory) {
|
||||
this._accessToken = await this._accessTokenFactory();
|
||||
this._setAuthorizationHeader(request);
|
||||
return await this._innerClient.send(request);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
_setAuthorizationHeader(request) {
|
||||
if (!request.headers) {
|
||||
request.headers = {};
|
||||
}
|
||||
if (this._accessToken) {
|
||||
request.headers[HeaderNames.Authorization] = `Bearer ${this._accessToken}`;
|
||||
}
|
||||
// don't remove the header if there isn't an access token factory, the user manually added the header in this case
|
||||
else if (this._accessTokenFactory) {
|
||||
if (request.headers[HeaderNames.Authorization]) {
|
||||
delete request.headers[HeaderNames.Authorization];
|
||||
}
|
||||
}
|
||||
}
|
||||
getCookieString(url) {
|
||||
return this._innerClient.getCookieString(url);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=AccessTokenHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/AccessTokenHttpClient.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AccessTokenHttpClient.js","sourceRoot":"","sources":["../../src/AccessTokenHttpClient.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAC;AAErE,eAAe;AACf,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IAKjD,YAAY,WAAuB,EAAE,kBAAgE;QACjG,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAoB;QAClC,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,mBAAmB,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC7G,oHAAoH;YACpH,UAAU,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;SACxD;QACD,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEvD,IAAI,UAAU,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE;YACvE,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACrD,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;YACtC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAChD;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,uBAAuB,CAAC,OAAoB;QAChD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAClB,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;SACxB;QACD,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,UAAU,IAAI,CAAC,YAAY,EAAE,CAAA;SAC7E;QACD,kHAAkH;aAC7G,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC/B,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE;gBAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;aACrD;SACJ;IACL,CAAC;IAEM,eAAe,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { HeaderNames } from \"./HeaderNames\";\r\nimport { HttpClient, HttpRequest, HttpResponse } from \"./HttpClient\";\r\n\r\n/** @private */\r\nexport class AccessTokenHttpClient extends HttpClient {\r\n private _innerClient: HttpClient;\r\n _accessToken: string | undefined;\r\n _accessTokenFactory: (() => string | Promise<string>) | undefined;\r\n\r\n constructor(innerClient: HttpClient, accessTokenFactory: (() => string | Promise<string>) | undefined) {\r\n super();\r\n\r\n this._innerClient = innerClient;\r\n this._accessTokenFactory = accessTokenFactory;\r\n }\r\n\r\n public async send(request: HttpRequest): Promise<HttpResponse> {\r\n let allowRetry = true;\r\n if (this._accessTokenFactory && (!this._accessToken || (request.url && request.url.indexOf(\"/negotiate?\") > 0))) {\r\n // don't retry if the request is a negotiate or if we just got a potentially new token from the access token factory\r\n allowRetry = false;\r\n this._accessToken = await this._accessTokenFactory();\r\n }\r\n this._setAuthorizationHeader(request);\r\n const response = await this._innerClient.send(request);\r\n\r\n if (allowRetry && response.statusCode === 401 && this._accessTokenFactory) {\r\n this._accessToken = await this._accessTokenFactory();\r\n this._setAuthorizationHeader(request);\r\n return await this._innerClient.send(request);\r\n }\r\n return response;\r\n }\r\n\r\n private _setAuthorizationHeader(request: HttpRequest) {\r\n if (!request.headers) {\r\n request.headers = {};\r\n }\r\n if (this._accessToken) {\r\n request.headers[HeaderNames.Authorization] = `Bearer ${this._accessToken}`\r\n }\r\n // don't remove the header if there isn't an access token factory, the user manually added the header in this case\r\n else if (this._accessTokenFactory) {\r\n if (request.headers[HeaderNames.Authorization]) {\r\n delete request.headers[HeaderNames.Authorization];\r\n }\r\n }\r\n }\r\n\r\n public getCookieString(url: string): string {\r\n return this._innerClient.getCookieString(url);\r\n }\r\n}"]}
|
||||
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.d.ts
vendored
Normal file
11
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { HttpClient, HttpRequest, HttpResponse } from "./HttpClient";
|
||||
import { ILogger } from "./ILogger";
|
||||
/** Default implementation of {@link @microsoft/signalr.HttpClient}. */
|
||||
export declare class DefaultHttpClient extends HttpClient {
|
||||
private readonly _httpClient;
|
||||
/** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
|
||||
constructor(logger: ILogger);
|
||||
/** @inheritDoc */
|
||||
send(request: HttpRequest): Promise<HttpResponse>;
|
||||
getCookieString(url: string): string;
|
||||
}
|
||||
41
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.js
vendored
Normal file
41
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
import { AbortError } from "./Errors";
|
||||
import { FetchHttpClient } from "./FetchHttpClient";
|
||||
import { HttpClient } from "./HttpClient";
|
||||
import { Platform } from "./Utils";
|
||||
import { XhrHttpClient } from "./XhrHttpClient";
|
||||
/** Default implementation of {@link @microsoft/signalr.HttpClient}. */
|
||||
export class DefaultHttpClient extends HttpClient {
|
||||
/** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
|
||||
constructor(logger) {
|
||||
super();
|
||||
if (typeof fetch !== "undefined" || Platform.isNode) {
|
||||
this._httpClient = new FetchHttpClient(logger);
|
||||
}
|
||||
else if (typeof XMLHttpRequest !== "undefined") {
|
||||
this._httpClient = new XhrHttpClient(logger);
|
||||
}
|
||||
else {
|
||||
throw new Error("No usable HttpClient found.");
|
||||
}
|
||||
}
|
||||
/** @inheritDoc */
|
||||
send(request) {
|
||||
// Check that abort was not signaled before calling send
|
||||
if (request.abortSignal && request.abortSignal.aborted) {
|
||||
return Promise.reject(new AbortError());
|
||||
}
|
||||
if (!request.method) {
|
||||
return Promise.reject(new Error("No method defined."));
|
||||
}
|
||||
if (!request.url) {
|
||||
return Promise.reject(new Error("No url defined."));
|
||||
}
|
||||
return this._httpClient.send(request);
|
||||
}
|
||||
getCookieString(url) {
|
||||
return this._httpClient.getCookieString(url);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=DefaultHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultHttpClient.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DefaultHttpClient.js","sourceRoot":"","sources":["../../src/DefaultHttpClient.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,uEAAuE;AACvE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAG7C,yJAAyJ;IACzJ,YAAmB,MAAe;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,QAAQ,CAAC,MAAM,EAAE;YACjD,IAAI,CAAC,WAAW,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;SAClD;aAAM,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE;YAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;SAChD;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAClD;IACL,CAAC;IAED,kBAAkB;IACX,IAAI,CAAC,OAAoB;QAC5B,wDAAwD;QACxD,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE;YACpD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACjB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YACd,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACvD;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEM,eAAe,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { AbortError } from \"./Errors\";\r\nimport { FetchHttpClient } from \"./FetchHttpClient\";\r\nimport { HttpClient, HttpRequest, HttpResponse } from \"./HttpClient\";\r\nimport { ILogger } from \"./ILogger\";\r\nimport { Platform } from \"./Utils\";\r\nimport { XhrHttpClient } from \"./XhrHttpClient\";\r\n\r\n/** Default implementation of {@link @microsoft/signalr.HttpClient}. */\r\nexport class DefaultHttpClient extends HttpClient {\r\n private readonly _httpClient: HttpClient;\r\n\r\n /** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */\r\n public constructor(logger: ILogger) {\r\n super();\r\n\r\n if (typeof fetch !== \"undefined\" || Platform.isNode) {\r\n this._httpClient = new FetchHttpClient(logger);\r\n } else if (typeof XMLHttpRequest !== \"undefined\") {\r\n this._httpClient = new XhrHttpClient(logger);\r\n } else {\r\n throw new Error(\"No usable HttpClient found.\");\r\n }\r\n }\r\n\r\n /** @inheritDoc */\r\n public send(request: HttpRequest): Promise<HttpResponse> {\r\n // Check that abort was not signaled before calling send\r\n if (request.abortSignal && request.abortSignal.aborted) {\r\n return Promise.reject(new AbortError());\r\n }\r\n\r\n if (!request.method) {\r\n return Promise.reject(new Error(\"No method defined.\"));\r\n }\r\n if (!request.url) {\r\n return Promise.reject(new Error(\"No url defined.\"));\r\n }\r\n\r\n return this._httpClient.send(request);\r\n }\r\n\r\n public getCookieString(url: string): string {\r\n return this._httpClient.getCookieString(url);\r\n }\r\n}\r\n"]}
|
||||
7
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.d.ts
vendored
Normal file
7
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.d.ts
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { IRetryPolicy, RetryContext } from "./IRetryPolicy";
|
||||
/** @private */
|
||||
export declare class DefaultReconnectPolicy implements IRetryPolicy {
|
||||
private readonly _retryDelays;
|
||||
constructor(retryDelays?: number[]);
|
||||
nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null;
|
||||
}
|
||||
14
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.js
vendored
Normal file
14
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.js
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// 0, 2, 10, 30 second delays before reconnect attempts.
|
||||
const DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];
|
||||
/** @private */
|
||||
export class DefaultReconnectPolicy {
|
||||
constructor(retryDelays) {
|
||||
this._retryDelays = retryDelays !== undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;
|
||||
}
|
||||
nextRetryDelayInMilliseconds(retryContext) {
|
||||
return this._retryDelays[retryContext.previousRetryCount];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=DefaultReconnectPolicy.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DefaultReconnectPolicy.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DefaultReconnectPolicy.js","sourceRoot":"","sources":["../../src/DefaultReconnectPolicy.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAIvE,wDAAwD;AACxD,MAAM,oCAAoC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAE3E,eAAe;AACf,MAAM,OAAO,sBAAsB;IAG/B,YAAY,WAAsB;QAC9B,IAAI,CAAC,YAAY,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,oCAAoC,CAAC;IAClH,CAAC;IAEM,4BAA4B,CAAC,YAA0B;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAC9D,CAAC;CACJ","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\nimport { IRetryPolicy, RetryContext } from \"./IRetryPolicy\";\r\n\r\n// 0, 2, 10, 30 second delays before reconnect attempts.\r\nconst DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];\r\n\r\n/** @private */\r\nexport class DefaultReconnectPolicy implements IRetryPolicy {\r\n private readonly _retryDelays: (number | null)[];\r\n\r\n constructor(retryDelays?: number[]) {\r\n this._retryDelays = retryDelays !== undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;\r\n }\r\n\r\n public nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null {\r\n return this._retryDelays[retryContext.previousRetryCount];\r\n }\r\n}\r\n"]}
|
||||
8
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.d.ts
vendored
Normal file
8
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.d.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/** @private */
|
||||
export declare function configureFetch(): boolean;
|
||||
/** @private */
|
||||
export declare function configureAbortController(): boolean;
|
||||
/** @private */
|
||||
export declare function getWS(): any;
|
||||
/** @private */
|
||||
export declare function getEventSource(): any;
|
||||
19
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.js
vendored
Normal file
19
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.js
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
/** @private */
|
||||
export function configureFetch() {
|
||||
return false;
|
||||
}
|
||||
/** @private */
|
||||
export function configureAbortController() {
|
||||
return false;
|
||||
}
|
||||
/** @private */
|
||||
export function getWS() {
|
||||
throw new Error("Trying to import 'ws' in the browser.");
|
||||
}
|
||||
/** @private */
|
||||
export function getEventSource() {
|
||||
throw new Error("Trying to import 'eventsource' in the browser.");
|
||||
}
|
||||
//# sourceMappingURL=DynamicImports.browser.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.browser.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DynamicImports.browser.js","sourceRoot":"","sources":["../../src/DynamicImports.browser.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAEvE,eAAe;AACf,MAAM,UAAU,cAAc;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,eAAe;AACf,MAAM,UAAU,wBAAwB;IACpC,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,eAAe;AACf,MAAM,UAAU,KAAK;IACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,CAAC;AAED,eAAe;AACf,MAAM,UAAU,cAAc;IAC1B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACtE,CAAC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n/** @private */\r\nexport function configureFetch(): boolean {\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function configureAbortController(): boolean {\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function getWS(): any {\r\n throw new Error(\"Trying to import 'ws' in the browser.\");\r\n}\r\n\r\n/** @private */\r\nexport function getEventSource(): any {\r\n throw new Error(\"Trying to import 'eventsource' in the browser.\");\r\n}"]}
|
||||
17
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.d.ts
vendored
Normal file
17
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.d.ts
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { CookieJar } from "@types/tough-cookie";
|
||||
/** @private */
|
||||
export declare function configureFetch(obj: {
|
||||
_fetchType?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
||||
_jar?: CookieJar;
|
||||
}): boolean;
|
||||
/** @private */
|
||||
export declare function configureAbortController(obj: {
|
||||
_abortControllerType: {
|
||||
prototype: AbortController;
|
||||
new (): AbortController;
|
||||
};
|
||||
}): boolean;
|
||||
/** @private */
|
||||
export declare function getWS(): any;
|
||||
/** @private */
|
||||
export declare function getEventSource(): any;
|
||||
45
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.js
vendored
Normal file
45
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.js
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
import { Platform } from "./Utils";
|
||||
/** @private */
|
||||
export function configureFetch(obj) {
|
||||
// Node added a fetch implementation to the global scope starting in v18.
|
||||
// We need to add a cookie jar in node to be able to share cookies with WebSocket
|
||||
if (typeof fetch === "undefined" || Platform.isNode) {
|
||||
// Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._jar = new (require("tough-cookie")).CookieJar();
|
||||
if (typeof fetch === "undefined") {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._fetchType = require("node-fetch");
|
||||
}
|
||||
else {
|
||||
// Use fetch from Node if available
|
||||
obj._fetchType = fetch;
|
||||
}
|
||||
// node-fetch doesn't have a nice API for getting and setting cookies
|
||||
// fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
obj._fetchType = require("fetch-cookie")(obj._fetchType, obj._jar);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/** @private */
|
||||
export function configureAbortController(obj) {
|
||||
if (typeof AbortController === "undefined") {
|
||||
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
|
||||
obj._abortControllerType = require("abort-controller");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/** @private */
|
||||
export function getWS() {
|
||||
return require("ws");
|
||||
}
|
||||
/** @private */
|
||||
export function getEventSource() {
|
||||
return require("eventsource");
|
||||
}
|
||||
//# sourceMappingURL=DynamicImports.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/DynamicImports.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"DynamicImports.js","sourceRoot":"","sources":["../../src/DynamicImports.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,uEAAuE;AAIvE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,eAAe;AACf,MAAM,UAAU,cAAc,CAAC,GACkB;IAE7C,yEAAyE;IACzE,iFAAiF;IACjF,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,QAAQ,CAAC,MAAM,EAAE;QACjD,iHAAiH;QACjH,8DAA8D;QAC9D,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAErD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAC9B,8DAA8D;YAC9D,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;SAC1C;aAAM;YACH,mCAAmC;YACnC,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC;SAC1B;QAED,qEAAqE;QACrE,2FAA2F;QAC3F,8DAA8D;QAC9D,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,eAAe;AACf,MAAM,UAAU,wBAAwB,CAAC,GAAqF;IAC1H,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;QACxC,gGAAgG;QAChG,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,eAAe;AACf,MAAM,UAAU,KAAK;IACjB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,eAAe;AACf,MAAM,UAAU,cAAc;IAC1B,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC","sourcesContent":["// Licensed to the .NET Foundation under one or more agreements.\r\n// The .NET Foundation licenses this file to you under the MIT license.\r\n\r\n// @ts-ignore: This will be removed from built files and is here to make the types available during dev work\r\nimport { CookieJar } from \"@types/tough-cookie\";\r\nimport { Platform } from \"./Utils\";\r\n\r\n/** @private */\r\nexport function configureFetch(obj: { _fetchType?: (input: RequestInfo, init?: RequestInit) => Promise<Response>,\r\n _jar?: CookieJar }): boolean\r\n{\r\n // Node added a fetch implementation to the global scope starting in v18.\r\n // We need to add a cookie jar in node to be able to share cookies with WebSocket\r\n if (typeof fetch === \"undefined\" || Platform.isNode) {\r\n // Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._jar = new (require(\"tough-cookie\")).CookieJar();\r\n\r\n if (typeof fetch === \"undefined\") {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._fetchType = require(\"node-fetch\");\r\n } else {\r\n // Use fetch from Node if available\r\n obj._fetchType = fetch;\r\n }\r\n\r\n // node-fetch doesn't have a nice API for getting and setting cookies\r\n // fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n obj._fetchType = require(\"fetch-cookie\")(obj._fetchType, obj._jar);\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function configureAbortController(obj: { _abortControllerType: { prototype: AbortController, new(): AbortController } }): boolean {\r\n if (typeof AbortController === \"undefined\") {\r\n // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide\r\n obj._abortControllerType = require(\"abort-controller\");\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** @private */\r\nexport function getWS(): any {\r\n return require(\"ws\");\r\n}\r\n\r\n/** @private */\r\nexport function getEventSource(): any {\r\n return require(\"eventsource\");\r\n}"]}
|
||||
101
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.d.ts
vendored
Normal file
101
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.d.ts
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import { HttpTransportType } from "./ITransport";
|
||||
/** Error thrown when an HTTP request fails. */
|
||||
export declare class HttpError extends Error {
|
||||
private __proto__;
|
||||
/** The HTTP status code represented by this error. */
|
||||
statusCode: number;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
* @param {number} statusCode The HTTP status code represented by this error.
|
||||
*/
|
||||
constructor(errorMessage: string, statusCode: number);
|
||||
}
|
||||
/** Error thrown when a timeout elapses. */
|
||||
export declare class TimeoutError extends Error {
|
||||
private __proto__;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage?: string);
|
||||
}
|
||||
/** Error thrown when an action is aborted. */
|
||||
export declare class AbortError extends Error {
|
||||
private __proto__;
|
||||
/** Constructs a new instance of {@link AbortError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage?: string);
|
||||
}
|
||||
/** Error thrown when the selected transport is unsupported by the browser. */
|
||||
/** @private */
|
||||
export declare class UnsupportedTransportError extends Error {
|
||||
private __proto__;
|
||||
/** The {@link @microsoft/signalr.HttpTransportType} this error occurred on. */
|
||||
transport: HttpTransportType;
|
||||
/** The type name of this error. */
|
||||
errorType: string;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message: string, transport: HttpTransportType);
|
||||
}
|
||||
/** Error thrown when the selected transport is disabled by the browser. */
|
||||
/** @private */
|
||||
export declare class DisabledTransportError extends Error {
|
||||
private __proto__;
|
||||
/** The {@link @microsoft/signalr.HttpTransportType} this error occurred on. */
|
||||
transport: HttpTransportType;
|
||||
/** The type name of this error. */
|
||||
errorType: string;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message: string, transport: HttpTransportType);
|
||||
}
|
||||
/** Error thrown when the selected transport cannot be started. */
|
||||
/** @private */
|
||||
export declare class FailedToStartTransportError extends Error {
|
||||
private __proto__;
|
||||
/** The {@link @microsoft/signalr.HttpTransportType} this error occurred on. */
|
||||
transport: HttpTransportType;
|
||||
/** The type name of this error. */
|
||||
errorType: string;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message: string, transport: HttpTransportType);
|
||||
}
|
||||
/** Error thrown when the negotiation with the server failed to complete. */
|
||||
/** @private */
|
||||
export declare class FailedToNegotiateWithServerError extends Error {
|
||||
private __proto__;
|
||||
/** The type name of this error. */
|
||||
errorType: string;
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
*/
|
||||
constructor(message: string);
|
||||
}
|
||||
/** Error thrown when multiple errors have occurred. */
|
||||
/** @private */
|
||||
export declare class AggregateErrors extends Error {
|
||||
private __proto__;
|
||||
/** The collection of errors this error is aggregating. */
|
||||
innerErrors: Error[];
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {Error[]} innerErrors The collection of errors this error is aggregating.
|
||||
*/
|
||||
constructor(message: string, innerErrors: Error[]);
|
||||
}
|
||||
134
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.js
vendored
Normal file
134
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.js
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
/** Error thrown when an HTTP request fails. */
|
||||
export class HttpError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
* @param {number} statusCode The HTTP status code represented by this error.
|
||||
*/
|
||||
constructor(errorMessage, statusCode) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(`${errorMessage}: Status code '${statusCode}'`);
|
||||
this.statusCode = statusCode;
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when a timeout elapses. */
|
||||
export class TimeoutError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage = "A timeout occurred.") {
|
||||
const trueProto = new.target.prototype;
|
||||
super(errorMessage);
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when an action is aborted. */
|
||||
export class AbortError extends Error {
|
||||
/** Constructs a new instance of {@link AbortError}.
|
||||
*
|
||||
* @param {string} errorMessage A descriptive error message.
|
||||
*/
|
||||
constructor(errorMessage = "An abort occurred.") {
|
||||
const trueProto = new.target.prototype;
|
||||
super(errorMessage);
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when the selected transport is unsupported by the browser. */
|
||||
/** @private */
|
||||
export class UnsupportedTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'UnsupportedTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when the selected transport is disabled by the browser. */
|
||||
/** @private */
|
||||
export class DisabledTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'DisabledTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when the selected transport cannot be started. */
|
||||
/** @private */
|
||||
export class FailedToStartTransportError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
|
||||
*/
|
||||
constructor(message, transport) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.transport = transport;
|
||||
this.errorType = 'FailedToStartTransportError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when the negotiation with the server failed to complete. */
|
||||
/** @private */
|
||||
export class FailedToNegotiateWithServerError extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
*/
|
||||
constructor(message) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.errorType = 'FailedToNegotiateWithServerError';
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
/** Error thrown when multiple errors have occurred. */
|
||||
/** @private */
|
||||
export class AggregateErrors extends Error {
|
||||
/** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
|
||||
*
|
||||
* @param {string} message A descriptive error message.
|
||||
* @param {Error[]} innerErrors The collection of errors this error is aggregating.
|
||||
*/
|
||||
constructor(message, innerErrors) {
|
||||
const trueProto = new.target.prototype;
|
||||
super(message);
|
||||
this.innerErrors = innerErrors;
|
||||
// Workaround issue in Typescript compiler
|
||||
// https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
|
||||
this.__proto__ = trueProto;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Errors.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/Errors.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
12
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.d.ts
vendored
Normal file
12
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.d.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { HttpClient, HttpRequest, HttpResponse } from "./HttpClient";
|
||||
import { ILogger } from "./ILogger";
|
||||
export declare class FetchHttpClient extends HttpClient {
|
||||
private readonly _abortControllerType;
|
||||
private readonly _fetchType;
|
||||
private readonly _jar?;
|
||||
private readonly _logger;
|
||||
constructor(logger: ILogger);
|
||||
/** @inheritDoc */
|
||||
send(request: HttpRequest): Promise<HttpResponse>;
|
||||
getCookieString(url: string): string;
|
||||
}
|
||||
139
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.js
vendored
Normal file
139
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.js
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
import { AbortError, HttpError, TimeoutError } from "./Errors";
|
||||
import { HttpClient, HttpResponse } from "./HttpClient";
|
||||
import { LogLevel } from "./ILogger";
|
||||
import { Platform, getGlobalThis, isArrayBuffer } from "./Utils";
|
||||
import { configureAbortController, configureFetch } from "./DynamicImports";
|
||||
export class FetchHttpClient extends HttpClient {
|
||||
constructor(logger) {
|
||||
super();
|
||||
this._logger = logger;
|
||||
// This is how you do "reference" arguments
|
||||
const fetchObj = { _fetchType: undefined, _jar: undefined };
|
||||
if (configureFetch(fetchObj)) {
|
||||
this._fetchType = fetchObj._fetchType;
|
||||
this._jar = fetchObj._jar;
|
||||
}
|
||||
else {
|
||||
this._fetchType = fetch.bind(getGlobalThis());
|
||||
}
|
||||
this._abortControllerType = AbortController;
|
||||
const abortObj = { _abortControllerType: this._abortControllerType };
|
||||
if (configureAbortController(abortObj)) {
|
||||
this._abortControllerType = abortObj._abortControllerType;
|
||||
}
|
||||
}
|
||||
/** @inheritDoc */
|
||||
async send(request) {
|
||||
// Check that abort was not signaled before calling send
|
||||
if (request.abortSignal && request.abortSignal.aborted) {
|
||||
throw new AbortError();
|
||||
}
|
||||
if (!request.method) {
|
||||
throw new Error("No method defined.");
|
||||
}
|
||||
if (!request.url) {
|
||||
throw new Error("No url defined.");
|
||||
}
|
||||
const abortController = new this._abortControllerType();
|
||||
let error;
|
||||
// Hook our abortSignal into the abort controller
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = () => {
|
||||
abortController.abort();
|
||||
error = new AbortError();
|
||||
};
|
||||
}
|
||||
// If a timeout has been passed in, setup a timeout to call abort
|
||||
// Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
|
||||
let timeoutId = null;
|
||||
if (request.timeout) {
|
||||
const msTimeout = request.timeout;
|
||||
timeoutId = setTimeout(() => {
|
||||
abortController.abort();
|
||||
this._logger.log(LogLevel.Warning, `Timeout from HTTP request.`);
|
||||
error = new TimeoutError();
|
||||
}, msTimeout);
|
||||
}
|
||||
if (request.content === "") {
|
||||
request.content = undefined;
|
||||
}
|
||||
if (request.content) {
|
||||
// Explicitly setting the Content-Type header for React Native on Android platform.
|
||||
request.headers = request.headers || {};
|
||||
if (isArrayBuffer(request.content)) {
|
||||
request.headers["Content-Type"] = "application/octet-stream";
|
||||
}
|
||||
else {
|
||||
request.headers["Content-Type"] = "text/plain;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
let response;
|
||||
try {
|
||||
response = await this._fetchType(request.url, {
|
||||
body: request.content,
|
||||
cache: "no-cache",
|
||||
credentials: request.withCredentials === true ? "include" : "same-origin",
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
...request.headers,
|
||||
},
|
||||
method: request.method,
|
||||
mode: "cors",
|
||||
redirect: "follow",
|
||||
signal: abortController.signal,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
this._logger.log(LogLevel.Warning, `Error from HTTP request. ${e}.`);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = null;
|
||||
}
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorMessage = await deserializeContent(response, "text");
|
||||
throw new HttpError(errorMessage || response.statusText, response.status);
|
||||
}
|
||||
const content = deserializeContent(response, request.responseType);
|
||||
const payload = await content;
|
||||
return new HttpResponse(response.status, response.statusText, payload);
|
||||
}
|
||||
getCookieString(url) {
|
||||
let cookies = "";
|
||||
if (Platform.isNode && this._jar) {
|
||||
// @ts-ignore: unused variable
|
||||
this._jar.getCookies(url, (e, c) => cookies = c.join("; "));
|
||||
}
|
||||
return cookies;
|
||||
}
|
||||
}
|
||||
function deserializeContent(response, responseType) {
|
||||
let content;
|
||||
switch (responseType) {
|
||||
case "arraybuffer":
|
||||
content = response.arrayBuffer();
|
||||
break;
|
||||
case "text":
|
||||
content = response.text();
|
||||
break;
|
||||
case "blob":
|
||||
case "document":
|
||||
case "json":
|
||||
throw new Error(`${responseType} is not supported.`);
|
||||
default:
|
||||
content = response.text();
|
||||
break;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
//# sourceMappingURL=FetchHttpClient.js.map
|
||||
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.js.map
vendored
Normal file
1
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/FetchHttpClient.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
15
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/HandshakeProtocol.d.ts
vendored
Normal file
15
src/Yavsc.Org/wwwroot/lib/microsoft/signalr/dist/esm/HandshakeProtocol.d.ts
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/** @private */
|
||||
export interface HandshakeRequestMessage {
|
||||
readonly protocol: string;
|
||||
readonly version: number;
|
||||
}
|
||||
/** @private */
|
||||
export interface HandshakeResponseMessage {
|
||||
readonly error: string;
|
||||
readonly minorVersion: number;
|
||||
}
|
||||
/** @private */
|
||||
export declare class HandshakeProtocol {
|
||||
writeHandshakeRequest(handshakeRequest: HandshakeRequestMessage): string;
|
||||
parseHandshakeResponse(data: any): [any, HandshakeResponseMessage];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue