xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.0-next.4 to 3.0.0-next.5
@@ -158,3 +158,3 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
remaining: end ? end - pos : 0, | ||
length: Buffer.length(buffers) | ||
length: Buffer.length && Buffer.length(buffers) | ||
}; | ||
@@ -161,0 +161,0 @@ } |
export namespace ERR { | ||
const MANIFEST: string; | ||
const NETWORK: string; | ||
const NETWORK_TIMEOUT: string; | ||
const OPTION: string; | ||
const M3U8: string; | ||
const DEMUX: string; | ||
const REMUX: string; | ||
const MSE: string; | ||
const DECRYPT: string; | ||
const MEDIA: string; | ||
const DRM: string; | ||
const OTHER: string; | ||
namespace SUB_TYPES { | ||
const FLV: string; | ||
const HLS: string; | ||
const MP4: string; | ||
const FMP4: string; | ||
const MSE_ADD_SB: string; | ||
const MSE_APPEND_BUFFER: string; | ||
const MSE_OTHER: string; | ||
const OPTION: string; | ||
} | ||
} | ||
export const ERR_CODE: { | ||
[x: string]: number; | ||
[x: string]: number | { | ||
HLS: number; | ||
FLV?: undefined; | ||
MP4?: undefined; | ||
FMP4?: undefined; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
FLV: number; | ||
HLS: number; | ||
MP4: number; | ||
FMP4: number; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
FMP4: number; | ||
MP4: number; | ||
HLS?: undefined; | ||
FLV?: undefined; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
MSE_ADD_SB: number; | ||
MSE_APPEND_BUFFER: number; | ||
MSE_OTHER: number; | ||
HLS?: undefined; | ||
FLV?: undefined; | ||
MP4?: undefined; | ||
FMP4?: undefined; | ||
}; | ||
}; | ||
export class StreamingError extends Error { | ||
static create(type: any, origin: any, payload: any, msg: any): StreamingError; | ||
static create(type: any, subType: any, origin: any, payload: any, msg: any): StreamingError; | ||
static network(error: any): StreamingError; | ||
constructor(type: any, origin: any, payload: any, msg: any); | ||
constructor(type: any, subType: any, origin: any, payload: any, msg: any); | ||
errorType: any; | ||
originError: any; | ||
ext: any; | ||
errorCode: number; | ||
errorCode: any; | ||
errorMessage: string; | ||
} |
@@ -17,13 +17,36 @@ import 'core-js/modules/es.reflect.construct.js'; | ||
var ERR = { | ||
MANIFEST: 'manifest', | ||
NETWORK: 'network', | ||
NETWORK_TIMEOUT: 'network_timeout', | ||
OPTION: 'option', | ||
M3U8: 'm3u8', | ||
DEMUX: 'demux', | ||
REMUX: 'remux', | ||
MSE: 'mse', | ||
DECRYPT: 'decrypt', | ||
OTHER: 'other' | ||
MEDIA: 'media', | ||
DRM: 'drm', | ||
OTHER: 'other', | ||
SUB_TYPES: { | ||
FLV: 'FLV', | ||
HLS: 'HLS', | ||
MP4: 'MP4', | ||
FMP4: 'FMP4', | ||
MSE_ADD_SB: 'MSE_ADD_SB', | ||
MSE_APPEND_BUFFER: 'MSE_APPEND_BUFFER', | ||
MSE_OTHER: 'MSE_OTHER', | ||
OPTION: 'OPTION' | ||
} | ||
}; | ||
var ERR_CODE = (_ERR_CODE = {}, _defineProperty(_ERR_CODE, ERR.OPTION, 500), _defineProperty(_ERR_CODE, ERR.NETWORK, 600), _defineProperty(_ERR_CODE, ERR.NETWORK_TIMEOUT, 601), _defineProperty(_ERR_CODE, ERR.M3U8, 900), _defineProperty(_ERR_CODE, ERR.DEMUX, 700), _defineProperty(_ERR_CODE, ERR.DECRYPT, 701), _defineProperty(_ERR_CODE, ERR.REMUX, 800), _defineProperty(_ERR_CODE, ERR.MSE, 1000), _defineProperty(_ERR_CODE, ERR.OTHER, 999), _ERR_CODE); | ||
var ERR_CODE = (_ERR_CODE = {}, _defineProperty(_ERR_CODE, ERR.MANIFEST, { | ||
HLS: 1100 | ||
}), _defineProperty(_ERR_CODE, ERR.NETWORK, 2100), _defineProperty(_ERR_CODE, ERR.NETWORK_TIMEOUT, 2101), _defineProperty(_ERR_CODE, ERR.DEMUX, { | ||
FLV: 3100, | ||
HLS: 3200, | ||
MP4: 3300, | ||
FMP4: 3400 | ||
}), _defineProperty(_ERR_CODE, ERR.REMUX, { | ||
FMP4: 4100, | ||
MP4: 4200 | ||
}), _defineProperty(_ERR_CODE, ERR.MEDIA, { | ||
MSE_ADD_SB: 5200, | ||
MSE_APPEND_BUFFER: 5201, | ||
MSE_OTHER: 5202 | ||
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8000), _ERR_CODE); | ||
var StreamingError = /*#__PURE__*/function (_Error) { | ||
@@ -34,3 +57,3 @@ _inherits(StreamingError, _Error); | ||
function StreamingError(type, origin, payload, msg) { | ||
function StreamingError(type, subType, origin, payload, msg) { | ||
var _this; | ||
@@ -44,3 +67,3 @@ | ||
_this.ext = payload; | ||
_this.errorCode = ERR_CODE[type]; | ||
_this.errorCode = ERR_CODE[type][subType] || ERR_CODE[type]; | ||
_this.errorMessage = _this.message; | ||
@@ -58,3 +81,3 @@ | ||
key: "create", | ||
value: function create(type, origin, payload, msg) { | ||
value: function create(type, subType, origin, payload, msg) { | ||
if (type instanceof StreamingError) { | ||
@@ -68,3 +91,3 @@ return type; | ||
if (!type) type = ERR.OTHER; | ||
return new StreamingError(type, origin, payload, msg); | ||
return new StreamingError(type, subType, origin, payload, msg); | ||
} | ||
@@ -76,3 +99,3 @@ }, { | ||
return new StreamingError(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, { | ||
return new StreamingError(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, null, { | ||
url: error === null || error === void 0 ? void 0 : error.url, | ||
@@ -79,0 +102,0 @@ response: error === null || error === void 0 ? void 0 : error.response, |
@@ -100,3 +100,3 @@ import 'core-js/modules/es.reflect.construct.js'; | ||
if (op) { | ||
op.promise.reject(new StreamingError(ERR.MSE, new MSEError(MSEErrorType.UPDATE_ERROR, event))); // Do not shift from queue, 'updateend' event will fire next | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_APPEND_BUFFER, event)); // Do not shift from queue, 'updateend' event will fire next | ||
} | ||
@@ -306,3 +306,3 @@ } | ||
} catch (error) { | ||
throw new StreamingError(ERR.MSE, error); | ||
throw new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_ADD_SB, error); | ||
} | ||
@@ -582,3 +582,3 @@ | ||
} catch (error) { | ||
op.promise.reject(new StreamingError(ERR.MSE, error)); | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error)); | ||
queue.shift(); | ||
@@ -585,0 +585,0 @@ |
@@ -8,3 +8,3 @@ export class FetchLoader { | ||
_aborted: boolean; | ||
load({ url, timeout, responseType, onProgress, onTimeout, range, transformResponse, request, params, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy, integrity }: { | ||
load({ url, timeout, responseType, onProgress, onTimeout, range, transformResponse, request, params, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy }: { | ||
url: any; | ||
@@ -28,3 +28,2 @@ timeout: any; | ||
referrerPolicy: any; | ||
integrity: any; | ||
}): Promise<void | { | ||
@@ -31,0 +30,0 @@ data: any; |
@@ -55,3 +55,4 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
value: function load(_ref) { | ||
var _this = this; | ||
var _this$_abortControlle, | ||
_this = this; | ||
@@ -75,6 +76,5 @@ var url = _ref.url, | ||
referrer = _ref.referrer, | ||
referrerPolicy = _ref.referrerPolicy, | ||
integrity = _ref.integrity; | ||
referrerPolicy = _ref.referrerPolicy; | ||
this._aborted = false; | ||
this._abortController = new AbortController(); | ||
this._abortController = typeof AbortController !== 'undefined' && new AbortController(); | ||
var init = { | ||
@@ -90,4 +90,3 @@ method: method, | ||
referrerPolicy: referrerPolicy, | ||
integrity: integrity, | ||
signal: this._abortController.signal | ||
signal: (_this$_abortControlle = this._abortController) === null || _this$_abortControlle === void 0 ? void 0 : _this$_abortControlle.signal | ||
}; | ||
@@ -249,3 +248,3 @@ var isTimeout = false; | ||
if (!this._response) { | ||
_context2.next = 15; | ||
_context2.next = 13; | ||
break; | ||
@@ -255,26 +254,23 @@ } | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
return this._response.body.cancel(); | ||
case 7: | ||
if (!this._reader) { | ||
_context2.next = 10; | ||
_context2.next = 8; | ||
break; | ||
} | ||
_context2.next = 10; | ||
_context2.next = 8; | ||
return this._reader.cancel(); | ||
case 10: | ||
_context2.next = 14; | ||
case 8: | ||
_context2.next = 12; | ||
break; | ||
case 12: | ||
_context2.prev = 12; | ||
case 10: | ||
_context2.prev = 10; | ||
_context2.t0 = _context2["catch"](4); | ||
case 14: | ||
case 12: | ||
this._response = this._reader = null; | ||
case 15: | ||
case 13: | ||
if (this._abortController) { | ||
@@ -289,3 +285,3 @@ try { | ||
case 16: | ||
case 14: | ||
case "end": | ||
@@ -295,3 +291,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, this, [[4, 12]]); | ||
}, _callee2, this, [[4, 10]]); | ||
})); | ||
@@ -383,13 +379,3 @@ | ||
value: function isSupported() { | ||
if (typeof ReadableStream !== 'undefined') { | ||
try { | ||
new ReadableStream({}); // eslint-disable-line no-new | ||
} catch (e) { | ||
return false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
return !!(typeof fetch !== 'undefined' && typeof AbortController !== 'undefined'); | ||
return !!(typeof fetch !== 'undefined'); | ||
} | ||
@@ -396,0 +382,0 @@ }]); |
@@ -132,3 +132,3 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
this._currentTask.exec().finally(function () { | ||
this._currentTask.exec().catch(function () {}).finally(function () { | ||
_this._processTask(); | ||
@@ -135,0 +135,0 @@ }); |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.0-next.4", | ||
"version": "3.0.0-next.5", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
746681
2928