Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

View File

@ -0,0 +1,64 @@
name: ci
on: [push, pull_request]
jobs:
should-skip:
continue-on-error: true
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should-skip-job: ${{steps.skip-check.outputs.should_skip}}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@v2.1.0
with:
github_token: ${{github.token}}
ci:
needs: should-skip
if: ${{needs.should-skip.outputs.should-skip-job != 'true' || github.ref == 'refs/heads/main'}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
env:
BROWSER_STACK_USERNAME: ${{secrets.BROWSER_STACK_USERNAME}}
BROWSER_STACK_ACCESS_KEY: ${{secrets.BROWSER_STACK_ACCESS_KEY}}
runs-on: ${{matrix.os}}
steps:
- name: checkout code
uses: actions/checkout@v2
- name: read node version from .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
shell: bash
id: nvm
- name: update apt cache on linux w/o browserstack
run: sudo apt-get update
- name: install ffmpeg/pulseaudio for firefox on linux w/o browserstack
run: sudo apt-get install ffmpeg pulseaudio
- name: start pulseaudio for firefox on linux w/o browserstack
run: pulseaudio -D
- name: setup node
uses: actions/setup-node@v2
with:
node-version: '${{steps.nvm.outputs.NVMRC}}'
cache: npm
# turn off the default setup-node problem watchers...
- run: echo "::remove-matcher owner=eslint-compact::"
- run: echo "::remove-matcher owner=eslint-stylish::"
- run: echo "::remove-matcher owner=tsc::"
- name: npm install
run: npm i --prefer-offline --no-audit
- name: run npm test
uses: GabrielBB/xvfb-action@v1
with:
run: npm run test

8
VApp/node_modules/@videojs/xhr/.idea/modules.xml generated vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/xhr.iml" filepath="$PROJECT_DIR$/.idea/xhr.iml" />
</modules>
</component>
</project>

6
VApp/node_modules/@videojs/xhr/.idea/vcs.xml generated vendored Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

12
VApp/node_modules/@videojs/xhr/.idea/xhr.iml generated vendored Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

1
VApp/node_modules/@videojs/xhr/.nvmrc generated vendored Normal file
View File

@ -0,0 +1 @@
10

27
VApp/node_modules/@videojs/xhr/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,27 @@
# XHR is an OPEN Open Source Project
-----------------------------------------
## What?
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
## Rules
There are a few basic ground-rules for contributors:
1. **No `--force` pushes** or modifying the Git history in any way.
1. **Non-master branches** ought to be used for ongoing work.
1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors.
1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor.
1. Contributors should attempt to adhere to the prevailing code-style.
## Releases
Declaring formal releases remains the prerogative of the project maintainer.
## Changes to this arrangement
This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
-----------------------------------------

19
VApp/node_modules/@videojs/xhr/LICENCE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2012 Raynos.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

434
VApp/node_modules/@videojs/xhr/README.md generated vendored Normal file
View File

@ -0,0 +1,434 @@
# xhr
> Originally forked from [naugtur/xhr](https://github.com/naugtur/xhr).
A small XMLHttpRequest wrapper. Designed for use with [browserify](http://browserify.org/), [webpack](https://webpack.github.io/) etc.
API is a subset of [request](https://github.com/request/request) so you can write code that works in both node.js and the browser by using `require('request')` in your code and telling your browser bundler to load `xhr` instead of `request`.
For browserify, add a [browser](https://github.com/substack/node-browserify#browser-field) field to your `package.json`:
```
"browser": {
"request": "@videojs/xhr"
}
```
For webpack, add a [resolve.alias](http://webpack.github.io/docs/configuration.html#resolve-alias) field to your configuration:
```
"resolve": {
"alias": {
"request$": "@videojs/xhr"
}
}
```
Browser support: IE8+ and everything else.
## Installation
```
npm install @videojs/xhr
```
## Example
```js
var xhr = require("@videojs/xhr")
xhr({
method: "post",
body: someJSONString,
uri: "/foo",
headers: {
"Content-Type": "application/json"
}
}, function (err, resp, body) {
// check resp.statusCode
})
```
## `var req = xhr(options, callback)`
```js
type XhrOptions = String | {
useXDR: Boolean?,
sync: Boolean?,
uri: String,
url: String,
method: String?,
timeout: Number?,
headers: Object?,
body: String? | Object?,
json: Boolean? | Object?,
username: String?,
password: String?,
withCredentials: Boolean?,
responseType: String?,
beforeSend: Function?
}
xhr := (XhrOptions, Callback<Response>) => Request
```
the returned object is either an [`XMLHttpRequest`][3] instance
or an [`XDomainRequest`][4] instance (if on IE8/IE9 &&
`options.useXDR` is set to `true`)
### XhrCallback
Your callback will be called once with the arguments
( [`Error`][5], `response` , `body` ) where the response is an object:
```js
{
body: Object||String,
statusCode: Number,
method: String,
headers: {},
url: String,
rawRequest: xhr
}
```
- `body`: HTTP response body - [`XMLHttpRequest.response`][6], [`XMLHttpRequest.responseText`][7] or
[`XMLHttpRequest.responseXML`][8] depending on the request type.
- `rawRequest`: Original [`XMLHttpRequest`][3] instance
or [`XDomainRequest`][4] instance (if on IE8/IE9 &&
`options.useXDR` is set to `true`)
- `headers`: A collection of headers where keys are header names converted to lowercase
Your callback will be called with an [`Error`][5] if there is an error in the browser that prevents sending the request.
A HTTP 500 response is not going to cause an error to be returned.
## Other signatures
* `var req = xhr(url, callback)` -
a simple string instead of the options. In this case, a GET request will be made to that url.
* `var req = xhr(url, options, callback)` -
the above may also be called with the standard set of options.
### Convience methods
* `var req = xhr.{post, put, patch, del, head, get}(url, callback)`
* `var req = xhr.{post, put, patch, del, head, get}(options, callback)`
* `var req = xhr.{post, put, patch, del, head, get}(url, options, callback)`
The `xhr` module has convience functions attached that will make requests with the given method.
Each function is named after its method, with the exception of `DELETE` which is called `xhr.del` for compatibility.
The method shorthands may be combined with the url-first form of `xhr` for succinct and descriptive requests. For example,
```js
xhr.post('/post-to-me', function(err, resp) {
console.log(resp.body)
})
```
or
```js
xhr.del('/delete-me', { headers: { my: 'auth' } }, function (err, resp) {
console.log(resp.statusCode);
})
```
## Options
### `options.method`
Specify the method the [`XMLHttpRequest`][3] should be opened
with. Passed to [`XMLHttpRequest.open`][2]. Defaults to "GET"
### `options.useXDR`
Specify whether this is a cross origin (CORS) request for IE<10.
Switches IE to use [`XDomainRequest`][4] instead of `XMLHttpRequest`.
Ignored in other browsers.
Note that headers cannot be set on an XDomainRequest instance.
### `options.sync`
Specify whether this is a synchrounous request. Note that when
this is true the callback will be called synchronously. In
most cases this option should not be used. Only use if you
know what you are doing!
### `options.body`
Pass in body to be send across the [`XMLHttpRequest`][3].
Generally should be a string. But anything that's valid as
a parameter to [`XMLHttpRequest.send`][1] should work (Buffer for file, etc.).
If `options.json` is `true`, then this must be a JSON-serializable object. `options.body` is passed to `JSON.stringify` and sent.
### `options.uri` or `options.url`
The uri to send a request to. Passed to [`XMLHttpRequest.open`][2]. `options.url` and `options.uri` are aliases for each other.
### `options.headers`
An object of headers that should be set on the request. The
key, value pair is passed to [`XMLHttpRequest.setRequestHeader`][9]
### `options.timeout`
Number of miliseconds to wait for response. Defaults to 0 (no timeout). Ignored when `options.sync` is true.
### `options.json`
Set to `true` to send request as `application/json` (see `options.body`) and parse response from JSON.
For backwards compatibility `options.json` can also be a valid JSON-serializable value to be sent to the server. Additionally the response body is still parsed as JSON
For sending booleans as JSON body see FAQ
### `options.withCredentials`
Specify whether user credentials are to be included in a cross-origin
request. Sets [`XMLHttpRequest.withCredentials`][10]. Defaults to false.
A wildcard `*` cannot be used in the `Access-Control-Allow-Origin` header when `withCredentials` is true.
The header needs to specify your origin explicitly or browser will abort the request.
### `options.responseType`
Determines the data type of the `response`. Sets [`XMLHttpRequest.responseType`][11]. For example, a `responseType` of `document` will return a parsed `Document` object as the `response.body` for an XML resource.
### `options.beforeSend`
A function being called right before the `send` method of the `XMLHttpRequest` or `XDomainRequest` instance is called. The `XMLHttpRequest` or `XDomainRequest` instance is passed as an argument.
### `options.xhr`
Pass an `XMLHttpRequest` object (or something that acts like one) to use instead of constructing a new one using the `XMLHttpRequest` or `XDomainRequest` constructors. Useful for testing.
## Helpers
This module exposes the following helpers on the `xhr` object.
### `xhr.httpHandler(callback, decodeResponseBody) => XhrCallback`
`httpHandler` is a wrapper for the [XhrCallback][] which returns an error for HTTP Status Codes 4xx and 5xx. Given a callback, it'll either return an error with the response body as the error's cause, or return the response body.
Usage like so:
```js
xhr({
uri: "https://example.com/foo",
responseType: 'arraybuffer'
}, xhr.httpHandler(function(err, responseBody) {
// we got an error if the XHR errored out or if the status code was 4xx/5xx
if (err) {
// error cause is coming soon to JavaScript https://github.com/tc39/proposal-error-cause
throw new Error(err, {cause: err.cause});
}
// this will log an ArrayBuffer
console.log(responseBody);
});
```
```js
xhr({
uri: "https://example.com/foo",
responseType: 'arraybuffer'
}, xhr.httpHandler(function(err, responseBody) {
if (err) {
throw new Error(err, {cause: err.cause});
}
// in this case, responseBody will be a String
console.log(responseBody);
},
// passing true as the second argument will cause httpHandler try and decode the response body into a string
true)
```
### `xhr.requestInterceptorsStorage` and `xhr.responseInterceptorsStorage`
have the following API:
```typescript
export interface NetworkRequest {
headers: Record<string, string>;
uri: string;
metadata: Record<string, unknown>;
body?: unknown;
retry?: Retry;
timeout?: number;
}
export interface NetworkResponse {
headers: Record<string, string>;
responseUrl: string;
body?: unknown;
responseType?: XMLHttpRequestResponseType;
}
export type Interceptor<T> = (payload: T) => T;
export interface InterceptorsStorage<T> {
enable(): void;
disable(): void;
getIsEnabled(): boolean;
reset(): void;
addInterceptor(type: string, interceptor: Interceptor<T>): boolean;
removeInterceptor(type: string, interceptor: Interceptor<T>): boolean;
clearInterceptorsByType(type: string): boolean;
clear(): boolean;
getForType(type: string): Set<Interceptor<T>>;
execute(type: string, payload: T): T;
}
```
Usage:
```js
xhr.requestInterceptorsStorage.enable();
xhr.responseInterceptorsStorage.enable();
xhr.requestInterceptorsStorage.addInterceptor('segment', (request) => {
// read / update NetworkRequest
return request;
});
xhr.responseInterceptorsStorage.addInterceptor('segement', (response) => {
// read / update NetworkResponse
return response;
});
xhr({
uri: 'https://host/segment',
responseType: 'arraybuffer',
requestType: 'segement'
}, function(err, response, responseBody) {
// your callback
});
```
### `xhr.retryManager`
has the following API
```typescript
export interface Retry {
getCurrentDelay(): number;
getCurrentMinPossibleDelay(): number;
getCurrentMaxPossibleDelay(): number;
getCurrentFuzzedDelay(): number;
shouldRetry(): boolean;
moveToNextAttempt(): void;
}
export interface RetryOptions {
maxAttempts?: number;
delayFactor?: number;
fuzzFactor?: number;
initialDelay?: number;
}
export interface RetryManager {
enable(): void;
disable(): void;
reset(): void;
getMaxAttempts(): number;
setMaxAttempts(maxAttempts: number): void;
getDelayFactor(): number;
setDelayFactor(delayFactor: number): void;
getFuzzFactor(): number;
setFuzzFactor(fuzzFactor: number): void;
getInitialDelay(): number;
setInitialDelay(initialDelay: number): void;
createRetry(options?: RetryOptions): Retry;
}
```
Usage:
```js
xhr.retryManager.enable();
xhr.retryManager.setMaxAttempts(2);
xhr({
uri: 'https://host/segment',
responseType: 'arraybuffer',
retry: xhr.retryManager.createRetry(),
}, function(err, response, responseBody) {
// your callback
});
// or override values for specific request:
xhr({
uri: 'https://host/segment',
responseType: 'arraybuffer',
retry: xhr.retryManager.createRetry({ maxAttempts: 3 }),
}, function(err, response, responseBody) {
// your callback
});
// you can combine interceptors/retry APIs if you dont have direct acces to the request:
xhr.requestInterceptorsStorage.addInterceptor('segment', (request) => {
// read / update NetworkRequest
request.retry = xhr.retryManager.createRetry();
return request;
});
```
## FAQ
- Why is my server's JSON response not parsed? I returned the right content-type.
- See `options.json` - you can set it to `true` on a GET request to tell `xhr` to parse the response body.
- Without `options.json` body is returned as-is (a string or when `responseType` is set and the browser supports it - a result of parsing JSON or XML)
- How do I send an object or array as POST body?
- `options.body` should be a string. You need to serialize your object before passing to `xhr` for sending.
- To serialize to JSON you can use
`options.json:true` with `options.body` for convenience - then `xhr` will do the serialization and set content-type accordingly.
- Where's stream API? `.pipe()` etc.
- Not implemented. You can't reasonably have that in the browser.
- Why can't I send `"true"` as body by passing it as `options.json` anymore?
- Accepting `true` as a value was a bug. Despite what `JSON.stringify` does, the string `"true"` is not valid JSON. If you're sending booleans as JSON, please consider wrapping them in an object or array to save yourself from more trouble in the future. To bring back the old behavior, hardcode `options.json` to `true` and set `options.body` to your boolean value.
- How do I add an `onprogress` listener?
- use `beforeSend` function for non-standard things that are browser specific. In this case:
```js
xhr({
...
beforeSend: function(xhrObject){
xhrObject.onprogress = function(){}
}
})
```
## Mocking Requests
You can override the constructor used to create new requests for testing. When you're making a new request:
```js
xhr({ xhr: new MockXMLHttpRequest() })
```
or you can override the constructors used to create requests at the module level:
```js
xhr.XMLHttpRequest = MockXMLHttpRequest
xhr.XDomainRequest = MockXDomainRequest
```
## MIT Licenced
[1]: http://xhr.spec.whatwg.org/#the-send()-method
[2]: http://xhr.spec.whatwg.org/#the-open()-method
[3]: http://xhr.spec.whatwg.org/#interface-xmlhttprequest
[4]: http://msdn.microsoft.com/en-us/library/ie/cc288060(v=vs.85).aspx
[5]: http://es5.github.com/#x15.11
[6]: http://xhr.spec.whatwg.org/#the-response-attribute
[7]: http://xhr.spec.whatwg.org/#the-responsetext-attribute
[8]: http://xhr.spec.whatwg.org/#the-responsexml-attribute
[9]: http://xhr.spec.whatwg.org/#the-setrequestheader()-method
[10]: http://xhr.spec.whatwg.org/#the-withcredentials-attribute
[11]: https://xhr.spec.whatwg.org/#the-responsetype-attribute

139
VApp/node_modules/@videojs/xhr/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,139 @@
export type BodyCallback = (
error: Error,
body: any
) => void;
export type HttpResponseHandler = (
callback: BodyCallback,
decodeResponseBody: boolean
) => XhrCallback;
export type XhrCallback = (
error: Error,
response: XhrResponse,
body: any
) => void;
export interface XhrResponse {
body: Object | string;
statusCode: number;
method: string;
headers: XhrHeaders;
url: string;
rawRequest: XMLHttpRequest;
}
export interface XhrHeaders {
[key: string]: string;
}
export interface XhrBaseConfig {
useXDR?: boolean;
sync?: boolean;
method?: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH';
timeout?: number;
headers?: XhrHeaders;
body?: string | any;
json?: boolean;
username?: string;
password?: string;
withCredentials?: boolean;
responseType?: '' | 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
requestType?: string;
metadata?: Record<string, unknown>;
retry?: Retry;
beforeSend?: (xhrObject: XMLHttpRequest) => void;
xhr?: XMLHttpRequest;
}
export interface XhrUriConfig extends XhrBaseConfig {
uri: string;
}
export interface XhrUrlConfig extends XhrBaseConfig {
url: string;
}
export interface XhrInstance {
(options: XhrUriConfig | XhrUrlConfig, callback: XhrCallback): any;
(url: string, callback: XhrCallback): any;
(url: string, options: XhrBaseConfig, callback: XhrCallback): any;
}
export interface Retry {
getCurrentDelay(): number;
getCurrentMinPossibleDelay(): number;
getCurrentMaxPossibleDelay(): number;
getCurrentFuzzedDelay(): number;
shouldRetry(): boolean;
moveToNextAttempt(): void;
}
export interface NetworkRequest {
headers: Record<string, string>;
uri: string;
metadata: Record<string, unknown>;
body?: unknown;
retry?: Retry;
timeout?: number;
}
export interface NetworkResponse {
headers: Record<string, string>;
responseUrl: string;
body?: unknown;
responseType?: XMLHttpRequestResponseType;
}
export type Interceptor<T> = (payload: T) => T;
export interface InterceptorsStorage<T> {
enable(): void;
disable(): void;
getIsEnabled(): boolean;
reset(): void;
addInterceptor(type: string, interceptor: Interceptor<T>): boolean;
removeInterceptor(type: string, interceptor: Interceptor<T>): boolean;
clearInterceptorsByType(type: string): boolean;
clear(): boolean;
getForType(type: string): Set<Interceptor<T>>;
execute(type: string, payload: T): T;
}
export interface RetryOptions {
maxAttempts?: number;
delayFactor?: number;
fuzzFactor?: number;
initialDelay?: number;
}
export interface RetryManager {
enable(): void;
disable(): void;
reset(): void;
getMaxAttempts(): number;
setMaxAttempts(maxAttempts: number): void;
getDelayFactor(): number;
setDelayFactor(delayFactor: number): void;
getFuzzFactor(): number;
setFuzzFactor(fuzzFactor: number): void;
getInitialDelay(): number;
setInitialDelay(initialDelay: number): void;
createRetry(options?: RetryOptions): Retry;
}
export interface XhrStatic extends XhrInstance {
del: XhrInstance;
get: XhrInstance;
head: XhrInstance;
patch: XhrInstance;
post: XhrInstance;
put: XhrInstance;
requestInterceptorsStorage: InterceptorsStorage<NetworkRequest>;
responseInterceptorsStorage: InterceptorsStorage<NetworkResponse>;
retryManager: RetryManager;
}
declare const Xhr: XhrStatic;
export default Xhr;

62
VApp/node_modules/@videojs/xhr/lib/http-handler.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
"use strict";
var window = require('global/window');
var httpResponseHandler = function httpResponseHandler(callback, decodeResponseBody) {
if (decodeResponseBody === void 0) {
decodeResponseBody = false;
}
return function (err, response, responseBody) {
// if the XHR failed, return that error
if (err) {
callback(err);
return;
} // if the HTTP status code is 4xx or 5xx, the request also failed
if (response.statusCode >= 400 && response.statusCode <= 599) {
var cause = responseBody;
if (decodeResponseBody) {
if (window.TextDecoder) {
var charset = getCharset(response.headers && response.headers['content-type']);
try {
cause = new TextDecoder(charset).decode(responseBody);
} catch (e) {}
} else {
cause = String.fromCharCode.apply(null, new Uint8Array(responseBody));
}
}
callback({
cause: cause
});
return;
} // otherwise, request succeeded
callback(null, responseBody);
};
};
function getCharset(contentTypeHeader) {
if (contentTypeHeader === void 0) {
contentTypeHeader = '';
}
return contentTypeHeader.toLowerCase().split(';').reduce(function (charset, contentType) {
var _contentType$split = contentType.split('='),
type = _contentType$split[0],
value = _contentType$split[1];
if (type.trim() === 'charset') {
return value.trim();
}
return charset;
}, 'utf-8');
}
module.exports = httpResponseHandler;

369
VApp/node_modules/@videojs/xhr/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,369 @@
"use strict";
var window = require("global/window");
var _extends = require("@babel/runtime/helpers/extends");
var isFunction = require('is-function');
var InterceptorsStorage = require('./interceptors.js');
var RetryManager = require("./retry.js");
createXHR.httpHandler = require('./http-handler.js');
createXHR.requestInterceptorsStorage = new InterceptorsStorage();
createXHR.responseInterceptorsStorage = new InterceptorsStorage();
createXHR.retryManager = new RetryManager();
/**
* @license
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
* Copyright (c) 2014 David Björklund
* Available under the MIT license
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
*/
var parseHeaders = function parseHeaders(headers) {
var result = {};
if (!headers) {
return result;
}
headers.trim().split('\n').forEach(function (row) {
var index = row.indexOf(':');
var key = row.slice(0, index).trim().toLowerCase();
var value = row.slice(index + 1).trim();
if (typeof result[key] === 'undefined') {
result[key] = value;
} else if (Array.isArray(result[key])) {
result[key].push(value);
} else {
result[key] = [result[key], value];
}
});
return result;
};
module.exports = createXHR; // Allow use of default import syntax in TypeScript
module.exports.default = createXHR;
createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
forEachArray(["get", "put", "post", "patch", "head", "delete"], function (method) {
createXHR[method === "delete" ? "del" : method] = function (uri, options, callback) {
options = initParams(uri, options, callback);
options.method = method.toUpperCase();
return _createXHR(options);
};
});
function forEachArray(array, iterator) {
for (var i = 0; i < array.length; i++) {
iterator(array[i]);
}
}
function isEmpty(obj) {
for (var i in obj) {
if (obj.hasOwnProperty(i)) return false;
}
return true;
}
function initParams(uri, options, callback) {
var params = uri;
if (isFunction(options)) {
callback = options;
if (typeof uri === "string") {
params = {
uri: uri
};
}
} else {
params = _extends({}, options, {
uri: uri
});
}
params.callback = callback;
return params;
}
function createXHR(uri, options, callback) {
options = initParams(uri, options, callback);
return _createXHR(options);
}
function _createXHR(options) {
if (typeof options.callback === "undefined") {
throw new Error("callback argument missing");
} // call all registered request interceptors for a given request type:
if (options.requestType && createXHR.requestInterceptorsStorage.getIsEnabled()) {
var requestInterceptorPayload = {
uri: options.uri || options.url,
headers: options.headers || {},
body: options.body,
metadata: options.metadata || {},
retry: options.retry,
timeout: options.timeout
};
var updatedPayload = createXHR.requestInterceptorsStorage.execute(options.requestType, requestInterceptorPayload);
options.uri = updatedPayload.uri;
options.headers = updatedPayload.headers;
options.body = updatedPayload.body;
options.metadata = updatedPayload.metadata;
options.retry = updatedPayload.retry;
options.timeout = updatedPayload.timeout;
}
var called = false;
var callback = function cbOnce(err, response, body) {
if (!called) {
called = true;
options.callback(err, response, body);
}
};
function readystatechange() {
// do not call load 2 times when response interceptors are enabled
// why do we even need this 2nd load?
if (xhr.readyState === 4 && !createXHR.responseInterceptorsStorage.getIsEnabled()) {
setTimeout(loadFunc, 0);
}
}
function getBody() {
// Chrome with requestType=blob throws errors arround when even testing access to responseText
var body = undefined;
if (xhr.response) {
body = xhr.response;
} else {
body = xhr.responseText || getXml(xhr);
}
if (isJson) {
try {
body = JSON.parse(body);
} catch (e) {}
}
return body;
}
function errorFunc(evt) {
clearTimeout(timeoutTimer);
clearTimeout(options.retryTimeout);
if (!(evt instanceof Error)) {
evt = new Error("" + (evt || "Unknown XMLHttpRequest Error"));
}
evt.statusCode = 0; // we would like to retry on error:
if (!aborted && createXHR.retryManager.getIsEnabled() && options.retry && options.retry.shouldRetry()) {
options.retryTimeout = setTimeout(function () {
options.retry.moveToNextAttempt(); // we want to re-use the same options and the same xhr object:
options.xhr = xhr;
_createXHR(options);
}, options.retry.getCurrentFuzzedDelay());
return;
} // call all registered response interceptors for a given request type:
if (options.requestType && createXHR.responseInterceptorsStorage.getIsEnabled()) {
var responseInterceptorPayload = {
headers: failureResponse.headers || {},
body: failureResponse.body,
responseUrl: xhr.responseURL,
responseType: xhr.responseType
};
var _updatedPayload = createXHR.responseInterceptorsStorage.execute(options.requestType, responseInterceptorPayload);
failureResponse.body = _updatedPayload.body;
failureResponse.headers = _updatedPayload.headers;
}
return callback(evt, failureResponse);
} // will load the data & process the response in a special response object
function loadFunc() {
if (aborted) return;
var status;
clearTimeout(timeoutTimer);
clearTimeout(options.retryTimeout);
if (options.useXDR && xhr.status === undefined) {
//IE8 CORS GET successful response doesn't have a status field, but body is fine
status = 200;
} else {
status = xhr.status === 1223 ? 204 : xhr.status;
}
var response = failureResponse;
var err = null;
if (status !== 0) {
response = {
body: getBody(),
statusCode: status,
method: method,
headers: {},
url: uri,
rawRequest: xhr
};
if (xhr.getAllResponseHeaders) {
//remember xhr can in fact be XDR for CORS in IE
response.headers = parseHeaders(xhr.getAllResponseHeaders());
}
} else {
err = new Error("Internal XMLHttpRequest Error");
} // call all registered response interceptors for a given request type:
if (options.requestType && createXHR.responseInterceptorsStorage.getIsEnabled()) {
var responseInterceptorPayload = {
headers: response.headers || {},
body: response.body,
responseUrl: xhr.responseURL,
responseType: xhr.responseType
};
var _updatedPayload2 = createXHR.responseInterceptorsStorage.execute(options.requestType, responseInterceptorPayload);
response.body = _updatedPayload2.body;
response.headers = _updatedPayload2.headers;
}
return callback(err, response, response.body);
}
var xhr = options.xhr || null;
if (!xhr) {
if (options.cors || options.useXDR) {
xhr = new createXHR.XDomainRequest();
} else {
xhr = new createXHR.XMLHttpRequest();
}
}
var key;
var aborted;
var uri = xhr.url = options.uri || options.url;
var method = xhr.method = options.method || "GET";
var body = options.body || options.data;
var headers = xhr.headers = options.headers || {};
var sync = !!options.sync;
var isJson = false;
var timeoutTimer;
var failureResponse = {
body: undefined,
headers: {},
statusCode: 0,
method: method,
url: uri,
rawRequest: xhr
};
if ("json" in options && options.json !== false) {
isJson = true;
headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user
if (method !== "GET" && method !== "HEAD") {
headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user
body = JSON.stringify(options.json === true ? body : options.json);
}
}
xhr.onreadystatechange = readystatechange;
xhr.onload = loadFunc;
xhr.onerror = errorFunc; // IE9 must have onprogress be set to a unique function.
xhr.onprogress = function () {// IE must die
};
xhr.onabort = function () {
aborted = true;
clearTimeout(options.retryTimeout);
};
xhr.ontimeout = errorFunc;
xhr.open(method, uri, !sync, options.username, options.password); //has to be after open
if (!sync) {
xhr.withCredentials = !!options.withCredentials;
} // Cannot set timeout with sync request
// not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
// both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
if (!sync && options.timeout > 0) {
timeoutTimer = setTimeout(function () {
if (aborted) return;
aborted = true; //IE9 may still call readystatechange
xhr.abort("timeout");
var e = new Error("XMLHttpRequest timeout");
e.code = "ETIMEDOUT";
errorFunc(e);
}, options.timeout);
}
if (xhr.setRequestHeader) {
for (key in headers) {
if (headers.hasOwnProperty(key)) {
xhr.setRequestHeader(key, headers[key]);
}
}
} else if (options.headers && !isEmpty(options.headers)) {
throw new Error("Headers cannot be set on an XDomainRequest object");
}
if ("responseType" in options) {
xhr.responseType = options.responseType;
}
if ("beforeSend" in options && typeof options.beforeSend === "function") {
options.beforeSend(xhr);
} // Microsoft Edge browser sends "undefined" when send is called with undefined value.
// XMLHttpRequest spec says to pass null as body to indicate no body
// See https://github.com/naugtur/xhr/issues/100.
xhr.send(body || null);
return xhr;
}
function getXml(xhr) {
// xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
// See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
try {
if (xhr.responseType === "document") {
return xhr.responseXML;
}
var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror";
if (xhr.responseType === "" && !firefoxBugTakenEffect) {
return xhr.responseXML;
}
} catch (e) {}
return null;
}
function noop() {}

104
VApp/node_modules/@videojs/xhr/lib/interceptors.js generated vendored Normal file
View File

@ -0,0 +1,104 @@
"use strict";
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var InterceptorsStorage = /*#__PURE__*/function () {
function InterceptorsStorage() {
this.typeToInterceptorsMap_ = new Map();
this.enabled_ = false;
}
var _proto = InterceptorsStorage.prototype;
_proto.getIsEnabled = function getIsEnabled() {
return this.enabled_;
};
_proto.enable = function enable() {
this.enabled_ = true;
};
_proto.disable = function disable() {
this.enabled_ = false;
};
_proto.reset = function reset() {
this.typeToInterceptorsMap_ = new Map();
this.enabled_ = false;
};
_proto.addInterceptor = function addInterceptor(type, interceptor) {
if (!this.typeToInterceptorsMap_.has(type)) {
this.typeToInterceptorsMap_.set(type, new Set());
}
var interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (interceptorsSet.has(interceptor)) {
// already have this interceptor
return false;
}
interceptorsSet.add(interceptor);
return true;
};
_proto.removeInterceptor = function removeInterceptor(type, interceptor) {
var interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (interceptorsSet && interceptorsSet.has(interceptor)) {
interceptorsSet.delete(interceptor);
return true;
}
return false;
};
_proto.clearInterceptorsByType = function clearInterceptorsByType(type) {
var interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (!interceptorsSet) {
return false;
}
this.typeToInterceptorsMap_.delete(type);
this.typeToInterceptorsMap_.set(type, new Set());
return true;
};
_proto.clear = function clear() {
if (!this.typeToInterceptorsMap_.size) {
return false;
}
this.typeToInterceptorsMap_ = new Map();
return true;
};
_proto.getForType = function getForType(type) {
return this.typeToInterceptorsMap_.get(type) || new Set();
};
_proto.execute = function execute(type, payload) {
var interceptors = this.getForType(type);
for (var _iterator = _createForOfIteratorHelperLoose(interceptors), _step; !(_step = _iterator()).done;) {
var interceptor = _step.value;
try {
payload = interceptor(payload);
} catch (e) {//ignore
}
}
return payload;
};
return InterceptorsStorage;
}();
module.exports = InterceptorsStorage;

133
VApp/node_modules/@videojs/xhr/lib/retry.js generated vendored Normal file
View File

@ -0,0 +1,133 @@
"use strict";
var RetryManager = /*#__PURE__*/function () {
function RetryManager() {
this.maxAttempts_ = 1;
this.delayFactor_ = 0.1;
this.fuzzFactor_ = 0.1;
this.initialDelay_ = 1000;
this.enabled_ = false;
}
var _proto = RetryManager.prototype;
_proto.getIsEnabled = function getIsEnabled() {
return this.enabled_;
};
_proto.enable = function enable() {
this.enabled_ = true;
};
_proto.disable = function disable() {
this.enabled_ = false;
};
_proto.reset = function reset() {
this.maxAttempts_ = 1;
this.delayFactor_ = 0.1;
this.fuzzFactor_ = 0.1;
this.initialDelay_ = 1000;
this.enabled_ = false;
};
_proto.getMaxAttempts = function getMaxAttempts() {
return this.maxAttempts_;
};
_proto.setMaxAttempts = function setMaxAttempts(maxAttempts) {
this.maxAttempts_ = maxAttempts;
};
_proto.getDelayFactor = function getDelayFactor() {
return this.delayFactor_;
};
_proto.setDelayFactor = function setDelayFactor(delayFactor) {
this.delayFactor_ = delayFactor;
};
_proto.getFuzzFactor = function getFuzzFactor() {
return this.fuzzFactor_;
};
_proto.setFuzzFactor = function setFuzzFactor(fuzzFactor) {
this.fuzzFactor_ = fuzzFactor;
};
_proto.getInitialDelay = function getInitialDelay() {
return this.initialDelay_;
};
_proto.setInitialDelay = function setInitialDelay(initialDelay) {
this.initialDelay_ = initialDelay;
};
_proto.createRetry = function createRetry(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
maxAttempts = _ref.maxAttempts,
delayFactor = _ref.delayFactor,
fuzzFactor = _ref.fuzzFactor,
initialDelay = _ref.initialDelay;
return new Retry({
maxAttempts: maxAttempts || this.maxAttempts_,
delayFactor: delayFactor || this.delayFactor_,
fuzzFactor: fuzzFactor || this.fuzzFactor_,
initialDelay: initialDelay || this.initialDelay_
});
};
return RetryManager;
}();
var Retry = /*#__PURE__*/function () {
function Retry(options) {
this.maxAttempts_ = options.maxAttempts;
this.delayFactor_ = options.delayFactor;
this.fuzzFactor_ = options.fuzzFactor;
this.currentDelay_ = options.initialDelay;
this.currentAttempt_ = 1;
}
var _proto2 = Retry.prototype;
_proto2.moveToNextAttempt = function moveToNextAttempt() {
this.currentAttempt_++;
var delayDelta = this.currentDelay_ * this.delayFactor_;
this.currentDelay_ = this.currentDelay_ + delayDelta;
};
_proto2.shouldRetry = function shouldRetry() {
return this.currentAttempt_ < this.maxAttempts_;
};
_proto2.getCurrentDelay = function getCurrentDelay() {
return this.currentDelay_;
};
_proto2.getCurrentMinPossibleDelay = function getCurrentMinPossibleDelay() {
return (1 - this.fuzzFactor_) * this.currentDelay_;
};
_proto2.getCurrentMaxPossibleDelay = function getCurrentMaxPossibleDelay() {
return (1 + this.fuzzFactor_) * this.currentDelay_;
}
/**
* For example fuzzFactor is 0.1
* This means ±10% deviation
* So if we have delay as 1000
* This function can generate any value from 900 to 1100
*/
;
_proto2.getCurrentFuzzedDelay = function getCurrentFuzzedDelay() {
var lowValue = this.getCurrentMinPossibleDelay();
var highValue = this.getCurrentMaxPossibleDelay();
return lowValue + Math.random() * (highValue - lowValue);
};
return Retry;
}();
module.exports = RetryManager;

56
VApp/node_modules/@videojs/xhr/package.json generated vendored Normal file
View File

@ -0,0 +1,56 @@
{
"name": "@videojs/xhr",
"version": "2.7.0",
"description": "small xhr abstraction",
"keywords": [
"xhr",
"http",
"xmlhttprequest",
"xhr2",
"browserify"
],
"author": "Raynos <raynos2@gmail.com>",
"repository": "git://github.com/videojs/xhr.git",
"main": "./lib/index.js",
"homepage": "https://github.com/videojs/xhr",
"contributors": [
{
"name": "Jake Verbaten"
},
{
"name": "Zbyszek Tenerowicz",
"email": "naugtur@gmail.com"
}
],
"bugs": "https://github.com/videojs/xhr/issues",
"typings": "./lib/index.d.ts",
"dependencies": {
"@babel/runtime": "^7.5.5",
"is-function": "^1.0.1",
"global": "~4.4.0"
},
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.8",
"@videojs/babel-config": "^0.1.0",
"for-each": "^0.3.2",
"pre-commit": "1.2.2",
"run-browser": "naugtur/run-browser",
"tap-spec": "^5.0.0",
"tape": "^4.0.0"
},
"license": "MIT",
"scripts": {
"prepublishOnly": "npm run build",
"start": "npm run build -- -w",
"build": "babel-config-cjs src -d lib",
"test:index": "run-browser test/index.js -b -m test/mock-server.js | tap-spec",
"test:interceptors": "run-browser test/interceptors.js -b -m test/mock-server.js | tap-spec",
"test:retry": "run-browser test/retry.js -b -m test/mock-server.js | tap-spec",
"test:http-handler": "run-browser test/http-handler.js -b -m test/mock-server.js | tap-spec",
"pretest": "npm run build",
"test": "npm run test:index && npm run test:http-handler && npm run test:interceptors && npm run test:retry",
"browser": "run-browser -m test/mock-server.js test/index.js"
}
}

50
VApp/node_modules/@videojs/xhr/src/http-handler.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
var window = require('global/window');
const httpResponseHandler = (callback, decodeResponseBody = false) => (err, response, responseBody) => {
// if the XHR failed, return that error
if (err) {
callback(err);
return;
}
// if the HTTP status code is 4xx or 5xx, the request also failed
if (response.statusCode >= 400 && response.statusCode <= 599) {
let cause = responseBody;
if (decodeResponseBody) {
if (window.TextDecoder) {
const charset = getCharset(response.headers && response.headers['content-type']);
try {
cause = new TextDecoder(charset).decode(responseBody);
} catch (e) {
}
} else {
cause = String.fromCharCode.apply(null, new Uint8Array(responseBody));
}
}
callback({cause});
return;
}
// otherwise, request succeeded
callback(null, responseBody);
};
function getCharset(contentTypeHeader = '') {
return contentTypeHeader
.toLowerCase()
.split(';')
.reduce((charset, contentType) => {
const [type, value] = contentType.split('=');
if (type.trim() === 'charset') {
return value.trim();
}
return charset;
}, 'utf-8');
}
module.exports = httpResponseHandler;

355
VApp/node_modules/@videojs/xhr/src/index.js generated vendored Normal file
View File

@ -0,0 +1,355 @@
"use strict";
var window = require("global/window")
var _extends = require("@babel/runtime/helpers/extends");
var isFunction = require('is-function');
var InterceptorsStorage = require('./interceptors.js');
var RetryManager = require("./retry.js");
createXHR.httpHandler = require('./http-handler.js');
createXHR.requestInterceptorsStorage = new InterceptorsStorage();
createXHR.responseInterceptorsStorage = new InterceptorsStorage();
createXHR.retryManager = new RetryManager();
/**
* @license
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
* Copyright (c) 2014 David Björklund
* Available under the MIT license
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
*/
var parseHeaders = function(headers) {
var result = {};
if (!headers) {
return result;
}
headers.trim().split('\n').forEach(function(row) {
var index = row.indexOf(':');
var key = row.slice(0, index).trim().toLowerCase();
var value = row.slice(index + 1).trim();
if (typeof(result[key]) === 'undefined') {
result[key] = value
} else if (Array.isArray(result[key])) {
result[key].push(value)
} else {
result[key] = [ result[key], value ]
}
});
return result;
};
module.exports = createXHR
// Allow use of default import syntax in TypeScript
module.exports.default = createXHR;
createXHR.XMLHttpRequest = window.XMLHttpRequest || noop
createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest
forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) {
createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) {
options = initParams(uri, options, callback)
options.method = method.toUpperCase()
return _createXHR(options)
}
})
function forEachArray(array, iterator) {
for (var i = 0; i < array.length; i++) {
iterator(array[i])
}
}
function isEmpty(obj){
for(var i in obj){
if(obj.hasOwnProperty(i)) return false
}
return true
}
function initParams(uri, options, callback) {
var params = uri
if (isFunction(options)) {
callback = options
if (typeof uri === "string") {
params = {uri:uri}
}
} else {
params = _extends({}, options, {uri: uri})
}
params.callback = callback
return params
}
function createXHR(uri, options, callback) {
options = initParams(uri, options, callback)
return _createXHR(options)
}
function _createXHR(options) {
if(typeof options.callback === "undefined"){
throw new Error("callback argument missing")
}
// call all registered request interceptors for a given request type:
if (options.requestType && createXHR.requestInterceptorsStorage.getIsEnabled()) {
const requestInterceptorPayload = {
uri: options.uri || options.url,
headers: options.headers || {},
body: options.body,
metadata: options.metadata || {},
retry: options.retry,
timeout: options.timeout,
}
const updatedPayload = createXHR.requestInterceptorsStorage.execute(options.requestType, requestInterceptorPayload);
options.uri = updatedPayload.uri;
options.headers = updatedPayload.headers;
options.body = updatedPayload.body;
options.metadata = updatedPayload.metadata;
options.retry = updatedPayload.retry;
options.timeout = updatedPayload.timeout;
}
var called = false
var callback = function cbOnce(err, response, body){
if(!called){
called = true
options.callback(err, response, body)
}
}
function readystatechange() {
// do not call load 2 times when response interceptors are enabled
// why do we even need this 2nd load?
if (xhr.readyState === 4 && !createXHR.responseInterceptorsStorage.getIsEnabled()) {
setTimeout(loadFunc, 0)
}
}
function getBody() {
// Chrome with requestType=blob throws errors arround when even testing access to responseText
var body = undefined
if (xhr.response) {
body = xhr.response
} else {
body = xhr.responseText || getXml(xhr)
}
if (isJson) {
try {
body = JSON.parse(body)
} catch (e) {}
}
return body
}
function errorFunc(evt) {
clearTimeout(timeoutTimer)
clearTimeout(options.retryTimeout)
if(!(evt instanceof Error)){
evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") )
}
evt.statusCode = 0
// we would like to retry on error:
if (!aborted && createXHR.retryManager.getIsEnabled() && options.retry && options.retry.shouldRetry()) {
options.retryTimeout = setTimeout(function() {
options.retry.moveToNextAttempt();
// we want to re-use the same options and the same xhr object:
options.xhr = xhr;
_createXHR(options);
}, options.retry.getCurrentFuzzedDelay());
return;
}
// call all registered response interceptors for a given request type:
if (options.requestType && createXHR.responseInterceptorsStorage.getIsEnabled()) {
const responseInterceptorPayload = {
headers: failureResponse.headers || {},
body: failureResponse.body,
responseUrl: xhr.responseURL,
responseType: xhr.responseType,
}
const updatedPayload = createXHR.responseInterceptorsStorage.execute(options.requestType, responseInterceptorPayload);
failureResponse.body = updatedPayload.body;
failureResponse.headers = updatedPayload.headers;
}
return callback(evt, failureResponse)
}
// will load the data & process the response in a special response object
function loadFunc() {
if (aborted) return
var status
clearTimeout(timeoutTimer)
clearTimeout(options.retryTimeout)
if(options.useXDR && xhr.status===undefined) {
//IE8 CORS GET successful response doesn't have a status field, but body is fine
status = 200
} else {
status = (xhr.status === 1223 ? 204 : xhr.status)
}
var response = failureResponse
var err = null
if (status !== 0){
response = {
body: getBody(),
statusCode: status,
method: method,
headers: {},
url: uri,
rawRequest: xhr
}
if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE
response.headers = parseHeaders(xhr.getAllResponseHeaders())
}
} else {
err = new Error("Internal XMLHttpRequest Error")
}
// call all registered response interceptors for a given request type:
if (options.requestType && createXHR.responseInterceptorsStorage.getIsEnabled()) {
const responseInterceptorPayload = {
headers: response.headers || {},
body: response.body,
responseUrl: xhr.responseURL,
responseType: xhr.responseType,
}
const updatedPayload = createXHR.responseInterceptorsStorage.execute(options.requestType, responseInterceptorPayload);
response.body = updatedPayload.body;
response.headers = updatedPayload.headers;
}
return callback(err, response, response.body)
}
var xhr = options.xhr || null
if (!xhr) {
if (options.cors || options.useXDR) {
xhr = new createXHR.XDomainRequest()
}else{
xhr = new createXHR.XMLHttpRequest()
}
}
var key
var aborted
var uri = xhr.url = options.uri || options.url
var method = xhr.method = options.method || "GET"
var body = options.body || options.data
var headers = xhr.headers = options.headers || {}
var sync = !!options.sync
var isJson = false
var timeoutTimer
var failureResponse = {
body: undefined,
headers: {},
statusCode: 0,
method: method,
url: uri,
rawRequest: xhr
}
if ("json" in options && options.json !== false) {
isJson = true
headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user
if (method !== "GET" && method !== "HEAD") {
headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user
body = JSON.stringify(options.json === true ? body : options.json)
}
}
xhr.onreadystatechange = readystatechange
xhr.onload = loadFunc
xhr.onerror = errorFunc
// IE9 must have onprogress be set to a unique function.
xhr.onprogress = function () {
// IE must die
}
xhr.onabort = function(){
aborted = true;
clearTimeout(options.retryTimeout)
}
xhr.ontimeout = errorFunc
xhr.open(method, uri, !sync, options.username, options.password)
//has to be after open
if(!sync) {
xhr.withCredentials = !!options.withCredentials
}
// Cannot set timeout with sync request
// not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
// both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
if (!sync && options.timeout > 0 ) {
timeoutTimer = setTimeout(function(){
if (aborted) return
aborted = true//IE9 may still call readystatechange
xhr.abort("timeout")
var e = new Error("XMLHttpRequest timeout")
e.code = "ETIMEDOUT"
errorFunc(e)
}, options.timeout )
}
if (xhr.setRequestHeader) {
for(key in headers){
if(headers.hasOwnProperty(key)){
xhr.setRequestHeader(key, headers[key])
}
}
} else if (options.headers && !isEmpty(options.headers)) {
throw new Error("Headers cannot be set on an XDomainRequest object")
}
if ("responseType" in options) {
xhr.responseType = options.responseType
}
if ("beforeSend" in options &&
typeof options.beforeSend === "function"
) {
options.beforeSend(xhr)
}
// Microsoft Edge browser sends "undefined" when send is called with undefined value.
// XMLHttpRequest spec says to pass null as body to indicate no body
// See https://github.com/naugtur/xhr/issues/100.
xhr.send(body || null)
return xhr
}
function getXml(xhr) {
// xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
// See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
try {
if (xhr.responseType === "document") {
return xhr.responseXML
}
var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror"
if (xhr.responseType === "" && !firefoxBugTakenEffect) {
return xhr.responseXML
}
} catch (e) {}
return null
}
function noop() {}

95
VApp/node_modules/@videojs/xhr/src/interceptors.js generated vendored Normal file
View File

@ -0,0 +1,95 @@
class InterceptorsStorage {
constructor() {
this.typeToInterceptorsMap_ = new Map();
this.enabled_ = false;
}
getIsEnabled() {
return this.enabled_;
}
enable() {
this.enabled_ = true;
}
disable() {
this.enabled_ = false;
}
reset() {
this.typeToInterceptorsMap_ = new Map();
this.enabled_ = false;
}
addInterceptor(type, interceptor) {
if (!this.typeToInterceptorsMap_.has(type)) {
this.typeToInterceptorsMap_.set(type, new Set());
}
const interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (interceptorsSet.has(interceptor)) {
// already have this interceptor
return false;
}
interceptorsSet.add(interceptor);
return true;
}
removeInterceptor(type, interceptor) {
const interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (interceptorsSet && interceptorsSet.has(interceptor)) {
interceptorsSet.delete(interceptor);
return true;
}
return false;
}
clearInterceptorsByType(type) {
const interceptorsSet = this.typeToInterceptorsMap_.get(type);
if (!interceptorsSet) {
return false;
}
this.typeToInterceptorsMap_.delete(type);
this.typeToInterceptorsMap_.set(type, new Set());
return true;
}
clear() {
if (!this.typeToInterceptorsMap_.size) {
return false;
}
this.typeToInterceptorsMap_ = new Map();
return true;
}
getForType(type) {
return this.typeToInterceptorsMap_.get(type) || new Set();
}
execute(type, payload) {
const interceptors = this.getForType(type);
for (const interceptor of interceptors) {
try {
payload = interceptor(payload);
} catch (e) {
//ignore
}
}
return payload;
}
}
module.exports = InterceptorsStorage;

118
VApp/node_modules/@videojs/xhr/src/retry.js generated vendored Normal file
View File

@ -0,0 +1,118 @@
class RetryManager {
constructor() {
this.maxAttempts_ = 1;
this.delayFactor_ = 0.1;
this.fuzzFactor_ = 0.1;
this.initialDelay_ = 1000;
this.enabled_ = false;
}
getIsEnabled() {
return this.enabled_;
}
enable() {
this.enabled_ = true;
}
disable() {
this.enabled_ = false;
}
reset() {
this.maxAttempts_ = 1;
this.delayFactor_ = 0.1;
this.fuzzFactor_ = 0.1;
this.initialDelay_ = 1000;
this.enabled_ = false;
}
getMaxAttempts() {
return this.maxAttempts_;
}
setMaxAttempts(maxAttempts) {
this.maxAttempts_ = maxAttempts;
}
getDelayFactor() {
return this.delayFactor_;
}
setDelayFactor(delayFactor) {
this.delayFactor_ = delayFactor;
}
getFuzzFactor() {
return this.fuzzFactor_;
}
setFuzzFactor(fuzzFactor) {
this.fuzzFactor_ = fuzzFactor;
}
getInitialDelay() {
return this.initialDelay_;
}
setInitialDelay(initialDelay) {
this.initialDelay_ = initialDelay;
}
createRetry({ maxAttempts, delayFactor, fuzzFactor, initialDelay } = {}) {
return new Retry({
maxAttempts: maxAttempts || this.maxAttempts_,
delayFactor: delayFactor || this.delayFactor_,
fuzzFactor: fuzzFactor || this.fuzzFactor_,
initialDelay: initialDelay || this.initialDelay_,
});
}
}
class Retry {
constructor(options) {
this.maxAttempts_ = options.maxAttempts;
this.delayFactor_ = options.delayFactor;
this.fuzzFactor_ = options.fuzzFactor;
this.currentDelay_ = options.initialDelay;
this.currentAttempt_ = 1;
}
moveToNextAttempt() {
this.currentAttempt_++;
const delayDelta = this.currentDelay_ * this.delayFactor_;
this.currentDelay_ = this.currentDelay_ + delayDelta;
}
shouldRetry() {
return this.currentAttempt_ < this.maxAttempts_;
}
getCurrentDelay() {
return this.currentDelay_;
}
getCurrentMinPossibleDelay() {
return (1 - this.fuzzFactor_) * this.currentDelay_;
}
getCurrentMaxPossibleDelay() {
return (1 + this.fuzzFactor_) * this.currentDelay_;
}
/**
* For example fuzzFactor is 0.1
* This means ±10% deviation
* So if we have delay as 1000
* This function can generate any value from 900 to 1100
*/
getCurrentFuzzedDelay() {
const lowValue = this.getCurrentMinPossibleDelay();
const highValue = this.getCurrentMaxPossibleDelay();
return lowValue + Math.random() * (highValue - lowValue);
}
}
module.exports = RetryManager;