xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.0-next.9 to 3.0.0-next.10
143
es/buffer.js
@@ -1,78 +0,53 @@ | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
var Buffer = /*#__PURE__*/function () { | ||
function Buffer() { | ||
_classCallCheck(this, Buffer); | ||
import { createClass as _createClass, classCallCheck as _classCallCheck } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
var Buffer = /* @__PURE__ */ function() { | ||
function Buffer2() { | ||
_classCallCheck(this, Buffer2); | ||
} | ||
_createClass(Buffer, null, [{ | ||
_createClass(Buffer2, null, [{ | ||
key: "start", | ||
value: | ||
/** | ||
* @param {TimeRanges} buf | ||
* @returns {number} | ||
*/ | ||
function start(buf) { | ||
if (!buf || !buf.length) return 0; // Safari bug: https://bit.ly/2trx6O8 | ||
if (buf.length === 1 && buf.end(0) - buf.start(0) < 1e-6) return 0; // Edge bug: https://bit.ly/2JYLPeB | ||
if (buf.length === 1 && buf.start(0) < 0) return 0; | ||
value: function start(buf) { | ||
if (!buf || !buf.length) | ||
return 0; | ||
if (buf.length === 1 && buf.end(0) - buf.start(0) < 1e-6) | ||
return 0; | ||
if (buf.length === 1 && buf.start(0) < 0) | ||
return 0; | ||
return buf.start(0); | ||
} | ||
/** | ||
* @param {TimeRanges} buf | ||
* @returns {number} | ||
*/ | ||
}, { | ||
key: "end", | ||
value: function end(buf) { | ||
if (!buf || !buf.length) return 0; // Safari bug: https://bit.ly/2trx6O8 | ||
if (buf.length === 1 && buf.end(0) - buf.start(0) < 1e-6) return 0; | ||
if (!buf || !buf.length) | ||
return 0; | ||
if (buf.length === 1 && buf.end(0) - buf.start(0) < 1e-6) | ||
return 0; | ||
return buf.end(buf.length - 1); | ||
} | ||
/** | ||
* @param {{buffered?: TimeRanges}} b | ||
* @returns {TimeRanges | void} | ||
*/ | ||
}, { | ||
key: "get", | ||
value: function get(b) { | ||
if (!b) return; | ||
if (!b) | ||
return; | ||
try { | ||
return b.buffered; | ||
} catch (error) {// ignore | ||
} catch (error) { | ||
} | ||
} | ||
/** | ||
* @param {TimeRanges} buf | ||
* @param {number} [maxHole] | ||
* @returns {[number,number][]} | ||
*/ | ||
}, { | ||
key: "buffers", | ||
value: function buffers(buf, maxHole) { | ||
if (!buf || !buf.length) return []; | ||
var buffers = []; | ||
if (!buf || !buf.length) | ||
return []; | ||
var buffers2 = []; | ||
for (var i = 0, l = buf.length; i < l; i++) { | ||
var bufLen = buffers.length; | ||
var bufLen = buffers2.length; | ||
if (!bufLen || !maxHole) { | ||
buffers.push([buf.start(i), buf.end(i)]); | ||
buffers2.push([buf.start(i), buf.end(i)]); | ||
} else { | ||
var last = buffers[bufLen - 1]; | ||
var last = buffers2[bufLen - 1]; | ||
var lastEnd = last[1]; | ||
var start = buf.start(i); | ||
if (start - lastEnd <= maxHole) { | ||
var end = buf.end(i); | ||
if (end > lastEnd) { | ||
@@ -82,41 +57,28 @@ last[1] = end; | ||
} else { | ||
buffers.push([buf.start(i), buf.end(i)]); | ||
buffers2.push([buf.start(i), buf.end(i)]); | ||
} | ||
} | ||
} | ||
return buffers; | ||
return buffers2; | ||
} | ||
/** | ||
* @param {TimeRanges} buf | ||
* @param {number} [maxHole] | ||
* @returns {{buffers:[number,number][],length:number}} | ||
*/ | ||
}, { | ||
key: "length", | ||
value: function length(buffers) { | ||
if (!buffers || !buffers.length) return 0; | ||
return buffers.reduce(function (a, c) { | ||
if (!buffers || !buffers.length) | ||
return 0; | ||
return buffers.reduce(function(a, c) { | ||
return a += c[1] - c[0]; | ||
}, 0); | ||
} | ||
/** | ||
* | ||
* @param {TimeRanges} buf | ||
* @param {number} [pos=0] | ||
* @param {number} [maxHole=0] | ||
* @returns {{start:number,end:number,buffers:[number,number][],index?:number,nextStart?:number,nextEnd?:number,prevStart?:number,prevEnd?:number}} | ||
*/ | ||
}, { | ||
key: "info", | ||
value: function info(buf) { | ||
var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var maxHole = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; | ||
if (!buf || !buf.length) return { | ||
start: 0, | ||
end: 0, | ||
buffers: [] | ||
}; | ||
var pos = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0; | ||
var maxHole = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0; | ||
if (!buf || !buf.length) | ||
return { | ||
start: 0, | ||
end: 0, | ||
buffers: [] | ||
}; | ||
var start = 0; | ||
@@ -129,7 +91,5 @@ var end = 0; | ||
var prevEnd = 0; | ||
var buffers = Buffer.buffers(buf, maxHole); | ||
var buffers = Buffer2.buffers(buf, maxHole); | ||
for (var i = 0, l = buffers.length; i < l; i++) { | ||
var item = buffers[i]; | ||
if (pos + maxHole >= item[0] && pos < item[1]) { | ||
@@ -148,23 +108,20 @@ start = item[0]; | ||
} | ||
return { | ||
start: start, | ||
end: end, | ||
index: index, | ||
buffers: buffers, | ||
nextStart: nextStart, | ||
nextEnd: nextEnd, | ||
prevStart: prevStart, | ||
prevEnd: prevEnd, | ||
start, | ||
end, | ||
index, | ||
buffers, | ||
nextStart, | ||
nextEnd, | ||
prevStart, | ||
prevEnd, | ||
currentTime: pos, | ||
behind: pos - start, | ||
remaining: end ? end - pos : 0, | ||
length: Buffer.length && Buffer.length(buffers) | ||
length: Buffer2.length && Buffer2.length(buffers) | ||
}; | ||
} | ||
}]); | ||
return Buffer; | ||
return Buffer2; | ||
}(); | ||
export { Buffer }; |
@@ -1,3 +0,2 @@ | ||
var isBrowser = typeof window !== 'undefined'; | ||
var isBrowser = typeof window !== "undefined"; | ||
export { isBrowser }; |
@@ -56,3 +56,3 @@ export namespace ERR { | ||
}; | ||
export class StreamingError extends Error { | ||
export class StreamingError { | ||
static create(type: any, subType: any, origin: any, payload: any, msg: any): StreamingError; | ||
@@ -65,3 +65,3 @@ static network(error: any): StreamingError; | ||
errorCode: any; | ||
errorMessage: string; | ||
errorMessage: any; | ||
} |
@@ -1,35 +0,22 @@ | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.reflect.construct.js'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _inherits from '@babel/runtime/helpers/inherits'; | ||
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn'; | ||
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf'; | ||
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, wrapNativeSuper as _wrapNativeSuper } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.error.cause.js"; | ||
var _ERR_CODE; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var ERR = { | ||
MANIFEST: 'manifest', | ||
NETWORK: 'network', | ||
NETWORK_TIMEOUT: 'network_timeout', | ||
DEMUX: 'demux', | ||
REMUX: 'remux', | ||
MEDIA: 'media', | ||
DRM: 'drm', | ||
OTHER: 'other', | ||
MANIFEST: "manifest", | ||
NETWORK: "network", | ||
NETWORK_TIMEOUT: "network_timeout", | ||
DEMUX: "demux", | ||
REMUX: "remux", | ||
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' | ||
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" | ||
} | ||
@@ -51,13 +38,9 @@ }; | ||
MSE_OTHER: 5202 | ||
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8000), _ERR_CODE); | ||
var StreamingError = /*#__PURE__*/function (_Error) { | ||
_inherits(StreamingError, _Error); | ||
var _super = _createSuper(StreamingError); | ||
function StreamingError(type, subType, origin, payload, msg) { | ||
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8e3), _ERR_CODE); | ||
var StreamingError = /* @__PURE__ */ function(_Error) { | ||
_inherits(StreamingError2, _Error); | ||
var _super = _createSuper(StreamingError2); | ||
function StreamingError2(type, subType, origin, payload, msg) { | ||
var _this; | ||
_classCallCheck(this, StreamingError); | ||
_classCallCheck(this, StreamingError2); | ||
_this = _super.call(this, msg || (origin === null || origin === void 0 ? void 0 : origin.message)); | ||
@@ -69,3 +52,2 @@ _this.errorType = type === ERR.NETWORK_TIMEOUT ? ERR.NETWORK : type; | ||
_this.errorMessage = _this.message; | ||
if (!_this.errorCode) { | ||
@@ -75,18 +57,16 @@ _this.errorType = ERR.OTHER; | ||
} | ||
return _this; | ||
} | ||
_createClass(StreamingError, null, [{ | ||
_createClass(StreamingError2, null, [{ | ||
key: "create", | ||
value: function create(type, subType, origin, payload, msg) { | ||
if (type instanceof StreamingError) { | ||
if (type instanceof StreamingError2) { | ||
return type; | ||
} else if (type instanceof Error) { | ||
origin = type; | ||
type = ''; | ||
type = ""; | ||
} | ||
if (!type) type = ERR.OTHER; | ||
return new StreamingError(type, subType, origin, payload, msg); | ||
if (!type) | ||
type = ERR.OTHER; | ||
return new StreamingError2(type, subType, origin, payload, msg); | ||
} | ||
@@ -97,4 +77,3 @@ }, { | ||
var _error$response; | ||
return new StreamingError(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, null, { | ||
return new StreamingError2(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, null, { | ||
url: error === null || error === void 0 ? void 0 : error.url, | ||
@@ -106,6 +85,4 @@ response: error === null || error === void 0 ? void 0 : error.response, | ||
}]); | ||
return StreamingError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
return StreamingError2; | ||
}(/* @__PURE__ */ _wrapNativeSuper(Error)); | ||
export { ERR, ERR_CODE, StreamingError }; |
var EVENT = { | ||
ERROR: 'error', | ||
TTFB: 'core.ttfb', | ||
LOAD_START: 'core.loadstart', | ||
LOAD_RESPONSE_HEADERS: 'core.loadresponseheaders', | ||
LOAD_COMPLETE: 'core.loadcomplete', | ||
LOAD_RETRY: 'core.loadretry', | ||
SOURCEBUFFER_CREATED: 'core.sourcebuffercreated', | ||
ANALYZE_DURATION_EXCEEDED: 'core.analyzedurationexceeded', | ||
REMOVE_BUFFER: 'core.removebuffer', | ||
BUFFEREOS: 'core.buffereos', | ||
KEYFRAME: 'core.keyframe', | ||
METADATA_PARSED: 'core.metadataparsed', | ||
SEI: 'core.sei', | ||
SEI_IN_TIME: 'core.seiintime', | ||
FLV_SCRIPT_DATA: 'core.flvscriptdata', | ||
LOWDECODE: 'core.lowdecode', | ||
SWITCH_URL_SUCCESS: 'core.switchurlsuccess', | ||
SWITCH_URL_FAILED: 'core.switchurlfailed', | ||
SPEED: 'core.speed', | ||
HLS_MANIFEST_LOADED: 'core.hlsmanifestloaded', | ||
HLS_LEVEL_LOADED: 'core.hlslevelloaded', | ||
STREAM_EXCEPTION: 'core.streamexception', | ||
LARGE_AV_FIRST_FRAME_GAP_DETECT: 'LARGE_AV_FIRST_FRAME_GAP_DETECT', | ||
LARGE_VIDEO_DTS_GAP_DETECT: 'LARGE_VIDEO_DTS_GAP_DETECT', | ||
LARGE_AUDIO_DTS_GAP_DETECT: 'LARGE_AUDIO_DTS_GAP_DETECT', | ||
AUDIO_GAP_DETECT: 'AUDIO_GAP_DETECT', | ||
AUDIO_OVERLAP_DETECT: 'AUDIO_OVERLAP_DETECT', | ||
MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT: 'MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT' | ||
ERROR: "error", | ||
TTFB: "core.ttfb", | ||
LOAD_START: "core.loadstart", | ||
LOAD_RESPONSE_HEADERS: "core.loadresponseheaders", | ||
LOAD_COMPLETE: "core.loadcomplete", | ||
LOAD_RETRY: "core.loadretry", | ||
SOURCEBUFFER_CREATED: "core.sourcebuffercreated", | ||
ANALYZE_DURATION_EXCEEDED: "core.analyzedurationexceeded", | ||
REMOVE_BUFFER: "core.removebuffer", | ||
BUFFEREOS: "core.buffereos", | ||
KEYFRAME: "core.keyframe", | ||
METADATA_PARSED: "core.metadataparsed", | ||
SEI: "core.sei", | ||
SEI_IN_TIME: "core.seiintime", | ||
FLV_SCRIPT_DATA: "core.flvscriptdata", | ||
LOWDECODE: "core.lowdecode", | ||
SWITCH_URL_SUCCESS: "core.switchurlsuccess", | ||
SWITCH_URL_FAILED: "core.switchurlfailed", | ||
SPEED: "core.speed", | ||
HLS_MANIFEST_LOADED: "core.hlsmanifestloaded", | ||
HLS_LEVEL_LOADED: "core.hlslevelloaded", | ||
STREAM_EXCEPTION: "core.streamexception", | ||
LARGE_AV_FIRST_FRAME_GAP_DETECT: "LARGE_AV_FIRST_FRAME_GAP_DETECT", | ||
LARGE_VIDEO_DTS_GAP_DETECT: "LARGE_VIDEO_DTS_GAP_DETECT", | ||
LARGE_AUDIO_DTS_GAP_DETECT: "LARGE_AUDIO_DTS_GAP_DETECT", | ||
AUDIO_GAP_DETECT: "AUDIO_GAP_DETECT", | ||
AUDIO_OVERLAP_DETECT: "AUDIO_OVERLAP_DETECT", | ||
MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT: "MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT" | ||
}; | ||
export { EVENT }; |
@@ -1,11 +0,11 @@ | ||
export { MSE, MSEError, MSEErrorType } from './mse.js'; | ||
export { Buffer } from './buffer.js'; | ||
export { NetLoader } from './net/index.js'; | ||
export { ERR, ERR_CODE, StreamingError } from './error.js'; | ||
export { EVENT } from './event.js'; | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, sleep } from './streaming-helper.js'; | ||
export { Logger } from './logger.js'; | ||
export { LoaderType, ResponseType } from './net/types.js'; | ||
export { GapService } from './services/gap.js'; | ||
export { SeiService } from './services/sei.js'; | ||
export { BandwidthService } from './services/bandwidth.js'; | ||
export { MSE, MSEError, MSEErrorType } from "./mse.js"; | ||
export { Buffer } from "./buffer.js"; | ||
export { NetLoader } from "./net/index.js"; | ||
export { ERR, ERR_CODE, StreamingError } from "./error.js"; | ||
export { EVENT } from "./event.js"; | ||
export { GapService } from "./services/gap.js"; | ||
export { SeiService } from "./services/sei.js"; | ||
export { BandwidthService } from "./services/bandwidth.js"; | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, sleep } from "./streaming-helper.js"; | ||
export { Logger } from "./logger.js"; | ||
export { LoaderType, ResponseType } from "./net/types.js"; |
15
es/is.js
@@ -1,14 +0,12 @@ | ||
import _typeof from '@babel/runtime/helpers/typeof'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.object.get-prototype-of.js'; | ||
import { typeof as _typeof } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.object.get-prototype-of.js"; | ||
var toString = Object.prototype.toString; | ||
function isObject(a) { | ||
return a !== null && _typeof(a) === 'object'; | ||
return a !== null && _typeof(a) === "object"; | ||
} | ||
function isPlainObject(val) { | ||
if (toString.call(val) !== '[object Object]') { | ||
if (toString.call(val) !== "[object Object]") { | ||
return false; | ||
} | ||
var prototype = Object.getPrototypeOf(val); | ||
@@ -18,5 +16,4 @@ return prototype === null || prototype === Object.prototype; | ||
function isDate(a) { | ||
return toString.call(a) === '[object Date]'; | ||
return toString.call(a) === "[object Date]"; | ||
} | ||
export { isDate, isObject, isPlainObject }; |
@@ -1,26 +0,19 @@ | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import 'core-js/modules/es.function.name.js'; | ||
import 'core-js/modules/es.array.concat.js'; | ||
var Logger = /*#__PURE__*/function () { | ||
function Logger(name) { | ||
_classCallCheck(this, Logger); | ||
this.name = name || ''; | ||
import { defineProperty as _defineProperty, createClass as _createClass, classCallCheck as _classCallCheck } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.function.name.js"; | ||
import "core-js/modules/es.array.concat.js"; | ||
var Logger = /* @__PURE__ */ function() { | ||
function Logger2(name) { | ||
_classCallCheck(this, Logger2); | ||
this.name = name || ""; | ||
this._prefix = "[".concat(this.name, "]"); | ||
} | ||
_createClass(Logger, [{ | ||
_createClass(Logger2, [{ | ||
key: "debug", | ||
value: function debug() { | ||
var _console; | ||
if (Logger.disabled) return; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
(_console = console).debug.apply(_console, [this._prefix].concat(args)); | ||
@@ -32,9 +25,7 @@ } | ||
var _console2; | ||
if (Logger.disabled) return; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
(_console2 = console).log.apply(_console2, [this._prefix].concat(args)); | ||
@@ -46,9 +37,7 @@ } | ||
var _console3; | ||
if (Logger.disabled) return; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
(_console3 = console).warn.apply(_console3, [this._prefix].concat(args)); | ||
@@ -60,9 +49,7 @@ } | ||
var _console4; | ||
if (Logger.disabled) return; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
(_console4 = console).error.apply(_console4, [this._prefix].concat(args)); | ||
@@ -74,8 +61,6 @@ } | ||
var _console5; | ||
if (Logger.disabled) return; | ||
if (Logger2.disabled) | ||
return; | ||
console.group(this._prefix); | ||
(_console5 = console).table.apply(_console5, arguments); | ||
console.groupEnd(); | ||
@@ -86,3 +71,3 @@ } | ||
value: function enable() { | ||
Logger.disabled = false; | ||
Logger2.disabled = false; | ||
} | ||
@@ -92,11 +77,8 @@ }, { | ||
value: function disable() { | ||
Logger.disabled = true; | ||
Logger2.disabled = true; | ||
} | ||
}]); | ||
return Logger; | ||
return Logger2; | ||
}(); | ||
_defineProperty(Logger, "disabled", true); | ||
export { Logger }; |
@@ -5,3 +5,3 @@ export type MSEErrorType = string; | ||
} | ||
export class MSEError extends Error { | ||
export class MSEError { | ||
/** | ||
@@ -30,8 +30,8 @@ * @param {MSEErrorType} type | ||
/** @type { MediaSource | null } */ | ||
mediaSource: MediaSource | null; | ||
_openPromise: Promise<any>; | ||
mediaSource: any | null; | ||
_openPromise: any; | ||
_queue: any; | ||
_sourceBuffer: any; | ||
get isOpened(): boolean; | ||
get duration(): number; | ||
get duration(): any; | ||
/** | ||
@@ -41,5 +41,5 @@ * @param { number } duration | ||
*/ | ||
updateDuration(duration: number): Promise<any>; | ||
updateDuration(duration: number): Promise; | ||
/** @return { Promise } */ | ||
open(): Promise<any>; | ||
open(): Promise; | ||
/** | ||
@@ -49,5 +49,5 @@ * @param { HTMLMediaElement } media | ||
*/ | ||
bindMedia(media: HTMLMediaElement): Promise<any>; | ||
bindMedia(media: HTMLMediaElement): Promise; | ||
/** @return { Promise } */ | ||
unbindMedia(): Promise<any>; | ||
unbindMedia(): Promise; | ||
/** | ||
@@ -63,3 +63,3 @@ * @param { string } type | ||
*/ | ||
changeType(type: string, mimeType: string): Promise<any>; | ||
changeType(type: string, mimeType: string): Promise; | ||
/** | ||
@@ -70,3 +70,3 @@ * @param { string } type | ||
*/ | ||
createOrChangeSource(type: string, mimeType: string): Promise<any>; | ||
createOrChangeSource(type: string, mimeType: string): Promise; | ||
/** | ||
@@ -77,3 +77,3 @@ * @param { string } type | ||
*/ | ||
append(type: string, buffer: BufferSource): Promise<any>; | ||
append(type: string, buffer: BufferSource): Promise; | ||
/** | ||
@@ -85,3 +85,3 @@ * @param { string } type | ||
*/ | ||
remove(type: string, startTime: number, endTime: number): Promise<any>; | ||
remove(type: string, startTime: number, endTime: number): Promise; | ||
clearBuffer(startTime: any, endTime: any): undefined; | ||
@@ -93,3 +93,3 @@ clearAllBuffer(): undefined; | ||
*/ | ||
endOfStream(reason?: EndOfStreamError): Promise<any>; | ||
endOfStream(reason?: EndOfStreamError): Promise; | ||
setLiveSeekableRange(start: any, end: any): void; | ||
@@ -111,4 +111,4 @@ /** | ||
bufferEnd(type: string): number; | ||
_enqueueOp(type: any, exec: any): Promise<any>; | ||
_enqueueBlockingOp(exec: any): Promise<any>; | ||
_enqueueOp(type: any, exec: any): any; | ||
_enqueueBlockingOp(exec: any): unknown; | ||
_startQueue(type: any): void; | ||
@@ -118,3 +118,1 @@ _onSBUpdateEnd: (type: any) => void; | ||
} | ||
declare const MediaSource: any; | ||
export {}; |
401
es/mse.js
@@ -1,49 +0,33 @@ | ||
import 'core-js/modules/es.reflect.construct.js'; | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _inherits from '@babel/runtime/helpers/inherits'; | ||
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn'; | ||
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf'; | ||
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper'; | ||
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.string.iterator.js'; | ||
import 'core-js/modules/web.dom-collections.iterator.js'; | ||
import 'core-js/modules/web.url.js'; | ||
import 'core-js/modules/web.url-search-params.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import 'core-js/modules/es.object.keys.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import 'core-js/modules/es.regexp.exec.js'; | ||
import { createPublicPromise } from './utils.js'; | ||
import { Buffer } from './buffer.js'; | ||
import { StreamingError, ERR } from './error.js'; | ||
import { isBrowser } from './env.js'; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var MediaSource = isBrowser ? window.MediaSource || window.WebKitMediaSource : null; | ||
/** @enum {string} */ | ||
import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, createClass as _createClass, wrapNativeSuper as _wrapNativeSuper, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.error.cause.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
import "core-js/modules/web.dom-collections.iterator.js"; | ||
import "core-js/modules/web.url.js"; | ||
import "core-js/modules/web.url-search-params.js"; | ||
import "core-js/modules/web.dom-collections.for-each.js"; | ||
import "core-js/modules/es.object.keys.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import { createPublicPromise } from "./utils.js"; | ||
import { Buffer } from "./buffer.js"; | ||
import { StreamingError, ERR } from "./error.js"; | ||
import { isBrowser } from "./env.js"; | ||
function getMediaSource() { | ||
try { | ||
return isBrowser ? window.MediaSource : null; | ||
} catch (e) { | ||
} | ||
} | ||
var MediaSource = getMediaSource(); | ||
var MSEErrorType = { | ||
UPDATE_ERROR: 'updateError' | ||
UPDATE_ERROR: "updateError" | ||
}; | ||
var MSEError = /*#__PURE__*/function (_Error) { | ||
_inherits(MSEError, _Error); | ||
var _super = _createSuper(MSEError); | ||
/** | ||
* @param {MSEErrorType} type | ||
* @param {any} [msg] | ||
*/ | ||
function MSEError(type, msg) { | ||
var MSEError = /* @__PURE__ */ function(_Error) { | ||
_inherits(MSEError2, _Error); | ||
var _super = _createSuper(MSEError2); | ||
function MSEError2(type, msg) { | ||
var _this; | ||
_classCallCheck(this, MSEError); | ||
_classCallCheck(this, MSEError2); | ||
_this = _super.call(this, msg || type); | ||
@@ -54,37 +38,19 @@ _this.type = type; | ||
} | ||
return _createClass(MSEError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
var MSE = /*#__PURE__*/function () { | ||
/** @type { HTMLMediaElement | null } */ | ||
/** @type { MediaSource | null } */ | ||
/** | ||
* @param {HTMLMediaElement} [media] | ||
*/ | ||
function MSE(media) { | ||
return _createClass(MSEError2); | ||
}(/* @__PURE__ */ _wrapNativeSuper(Error)); | ||
var MSE = /* @__PURE__ */ function() { | ||
function MSE2(media) { | ||
var _this2 = this; | ||
_classCallCheck(this, MSE); | ||
_classCallCheck(this, MSE2); | ||
_defineProperty(this, "media", null); | ||
_defineProperty(this, "mediaSource", null); | ||
_defineProperty(this, "_openPromise", createPublicPromise()); | ||
_defineProperty(this, "_queue", Object.create(null)); | ||
_defineProperty(this, "_sourceBuffer", Object.create(null)); | ||
_defineProperty(this, "_onSBUpdateEnd", function (type) { | ||
_defineProperty(this, "_queue", /* @__PURE__ */ Object.create(null)); | ||
_defineProperty(this, "_sourceBuffer", /* @__PURE__ */ Object.create(null)); | ||
_defineProperty(this, "_onSBUpdateEnd", function(type) { | ||
var queue = _this2._queue[type]; | ||
if (queue) { | ||
var op = queue.shift(); | ||
if (op) { | ||
op.promise.resolve(); | ||
_this2._startQueue(type); | ||
@@ -94,24 +60,19 @@ } | ||
}); | ||
_defineProperty(this, "_onSBUpdateError", function (type, event) { | ||
_defineProperty(this, "_onSBUpdateError", function(type, event) { | ||
var queue = _this2._queue[type]; | ||
if (queue) { | ||
var op = queue[0]; | ||
if (op) { | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_APPEND_BUFFER, 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)); | ||
} | ||
} | ||
}); | ||
if (media) this.bindMedia(media); | ||
if (media) | ||
this.bindMedia(media); | ||
} | ||
_createClass(MSE, [{ | ||
_createClass(MSE2, [{ | ||
key: "isOpened", | ||
get: function get() { | ||
var _this$mediaSource; | ||
return ((_this$mediaSource = this.mediaSource) === null || _this$mediaSource === void 0 ? void 0 : _this$mediaSource.readyState) === 'open'; | ||
return ((_this$mediaSource = this.mediaSource) === null || _this$mediaSource === void 0 ? void 0 : _this$mediaSource.readyState) === "open"; | ||
} | ||
@@ -122,10 +83,4 @@ }, { | ||
var _this$mediaSource2; | ||
return ((_this$mediaSource2 = this.mediaSource) === null || _this$mediaSource2 === void 0 ? void 0 : _this$mediaSource2.duration) || -1; | ||
} | ||
/** | ||
* @param { number } duration | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
@@ -135,9 +90,7 @@ key: "updateDuration", | ||
var _this3 = this; | ||
return this._enqueueBlockingOp(function () { | ||
if (_this3.mediaSource) _this3.mediaSource.duration = duration; | ||
return this._enqueueBlockingOp(function() { | ||
if (_this3.mediaSource) | ||
_this3.mediaSource.duration = duration; | ||
}); | ||
} | ||
/** @return { Promise } */ | ||
}, { | ||
@@ -147,31 +100,20 @@ key: "open", | ||
var _this4 = this; | ||
if (this._openPromise.used && !this.isOpened && this.mediaSource) { | ||
var ms = this.mediaSource; | ||
var onOpen = function onOpen() { | ||
ms.removeEventListener('sourceopen', onOpen); | ||
var onOpen = function onOpen2() { | ||
ms.removeEventListener("sourceopen", onOpen2); | ||
_this4._openPromise.resolve(); | ||
}; | ||
ms.addEventListener('sourceopen', onOpen); | ||
ms.addEventListener("sourceopen", onOpen); | ||
this._openPromise = createPublicPromise(); | ||
} | ||
return this._openPromise; | ||
} | ||
/** | ||
* @param { HTMLMediaElement } media | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
key: "bindMedia", | ||
value: function () { | ||
var _bindMedia = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(media) { | ||
value: function() { | ||
var _bindMedia = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(media) { | ||
var _this5 = this; | ||
var ms, onOpen; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -184,6 +126,4 @@ switch (_context.prev = _context.next) { | ||
} | ||
_context.next = 3; | ||
return this.unbindMedia(); | ||
case 3: | ||
@@ -194,5 +134,3 @@ if (!(!media || !MediaSource)) { | ||
} | ||
throw new Error('Param media or MediaSource does not exist'); | ||
throw new Error("Param media or MediaSource does not exist"); | ||
case 5: | ||
@@ -202,13 +140,9 @@ this.media = media; | ||
media.src = URL.createObjectURL(ms); | ||
onOpen = function onOpen() { | ||
ms.removeEventListener('sourceopen', onOpen); | ||
onOpen = function onOpen2() { | ||
ms.removeEventListener("sourceopen", onOpen2); | ||
URL.revokeObjectURL(media.src); | ||
_this5._openPromise.resolve(); | ||
}; | ||
ms.addEventListener('sourceopen', onOpen); | ||
ms.addEventListener("sourceopen", onOpen); | ||
return _context.abrupt("return", this._openPromise); | ||
case 11: | ||
@@ -221,31 +155,25 @@ case "end": | ||
})); | ||
function bindMedia(_x) { | ||
return _bindMedia.apply(this, arguments); | ||
} | ||
return bindMedia; | ||
}() | ||
/** @return { Promise } */ | ||
}, { | ||
key: "unbindMedia", | ||
value: function () { | ||
var _unbindMedia = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
value: function() { | ||
var _unbindMedia = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() { | ||
var _this6 = this; | ||
var ms; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
var ms, hasMetadata, mseOpen; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!this._openPromise.used) this._openPromise.resolve(); | ||
if (!this._openPromise.used) | ||
this._openPromise.resolve(); | ||
ms = this.mediaSource; | ||
if (ms) { | ||
Object.keys(this._queue).forEach(function (t) { | ||
Object.keys(this._queue).forEach(function(t) { | ||
var queue = _this6._queue[t]; | ||
if (queue) { | ||
queue.forEach(function (x) { | ||
queue.forEach(function(x) { | ||
return x.promise.resolve; | ||
@@ -255,34 +183,29 @@ }); | ||
}); | ||
if (ms.readyState === 'open') { | ||
hasMetadata = !!this.media && this.media.readyState >= 1; | ||
mseOpen = ms.readyState === "open"; | ||
if (hasMetadata && mseOpen) { | ||
try { | ||
ms.endOfStream(); | ||
} catch (error) {// ignore | ||
} catch (error) { | ||
} | ||
} | ||
Object.keys(this._sourceBuffer).forEach(function (k) { | ||
Object.keys(this._sourceBuffer).forEach(function(k) { | ||
try { | ||
ms.removeSourceBuffer(_this6._sourceBuffer[k]); | ||
} catch (error) {// ignore | ||
} catch (error) { | ||
} | ||
}); | ||
} | ||
if (this.media) { | ||
this.media.removeAttribute('src'); | ||
this.media.removeAttribute("src"); | ||
try { | ||
this.media.load(); | ||
} catch (error) {// ignore | ||
} catch (error) { | ||
} | ||
this.media = null; | ||
} | ||
this.mediaSource = null; | ||
this._openPromise = createPublicPromise(); | ||
this._queue = Object.create(null); | ||
this._sourceBuffer = Object.create(null); | ||
this._queue = /* @__PURE__ */ Object.create(null); | ||
this._sourceBuffer = /* @__PURE__ */ Object.create(null); | ||
case 8: | ||
@@ -295,20 +218,13 @@ case "end": | ||
})); | ||
function unbindMedia() { | ||
return _unbindMedia.apply(this, arguments); | ||
} | ||
return unbindMedia; | ||
}() | ||
/** | ||
* @param { string } type | ||
* @param { string } mimeType | ||
*/ | ||
}, { | ||
key: "createSource", | ||
value: function createSource(type, mimeType) { | ||
if (this._sourceBuffer[type] || !this.mediaSource) return; | ||
if (this._sourceBuffer[type] || !this.mediaSource) | ||
return; | ||
var sb; | ||
try { | ||
@@ -319,13 +235,6 @@ sb = this._sourceBuffer[type] = this.mediaSource.addSourceBuffer(mimeType); | ||
} | ||
sb.mimeType = mimeType; | ||
sb.addEventListener('updateend', this._onSBUpdateEnd.bind(this, type)); | ||
sb.addEventListener('error', this._onSBUpdateError.bind(this, type)); | ||
sb.addEventListener("updateend", this._onSBUpdateEnd.bind(this, type)); | ||
sb.addEventListener("error", this._onSBUpdateError.bind(this, type)); | ||
} | ||
/** | ||
* @param { string } type | ||
* @param { string } mimeType | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
@@ -335,13 +244,8 @@ key: "changeType", | ||
var sb = this._sourceBuffer[type]; | ||
if (!this.mediaSource || !sb || sb.mimeType === mimeType || typeof sb.changeType !== 'function') return Promise.resolve(); | ||
return this._enqueueOp(function () { | ||
if (!this.mediaSource || !sb || sb.mimeType === mimeType || typeof sb.changeType !== "function") | ||
return Promise.resolve(); | ||
return this._enqueueOp(function() { | ||
sb.changeType(mimeType); | ||
}); | ||
} | ||
/** | ||
* @param { string } type | ||
* @param { string } mimeType | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
@@ -353,8 +257,2 @@ key: "createOrChangeSource", | ||
} | ||
/** | ||
* @param { string } type | ||
* @param { BufferSource } buffer | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
@@ -364,22 +262,14 @@ key: "append", | ||
var _this7 = this; | ||
if (!buffer || !buffer.byteLength) { | ||
return Promise.resolve(); | ||
} | ||
if (!this._sourceBuffer[type]) return Promise.resolve(); | ||
return this._enqueueOp(type, function () { | ||
if (!this._sourceBuffer[type]) | ||
return Promise.resolve(); | ||
return this._enqueueOp(type, function() { | ||
var _this7$_sourceBuffer$; | ||
if (!_this7.mediaSource) return; | ||
if (!_this7.mediaSource) | ||
return; | ||
(_this7$_sourceBuffer$ = _this7._sourceBuffer[type]) === null || _this7$_sourceBuffer$ === void 0 ? void 0 : _this7$_sourceBuffer$.appendBuffer(buffer); | ||
}); | ||
} | ||
/** | ||
* @param { string } type | ||
* @param { number } startTime | ||
* @param { number } endTime | ||
* @return { Promise } | ||
*/ | ||
}, { | ||
@@ -389,14 +279,12 @@ key: "remove", | ||
var _this8 = this; | ||
if (Object.keys(this._sourceBuffer).length === 1) return; | ||
return this._enqueueOp(type, function () { | ||
if (!_this8.mediaSource) return; | ||
if (Object.keys(this._sourceBuffer).length === 1) | ||
return Promise.resolve(); | ||
return this._enqueueOp(type, function() { | ||
if (!_this8.mediaSource) | ||
return; | ||
var sb = _this8._sourceBuffer[type]; | ||
if (startTime >= endTime || !sb) { | ||
_this8._onSBUpdateEnd(type); | ||
return; | ||
} | ||
sb.remove(startTime, endTime); | ||
@@ -409,7 +297,7 @@ }); | ||
var _this9 = this; | ||
var p; | ||
Object.keys(this._sourceBuffer).forEach(function (k) { | ||
p = _this9._enqueueOp(k, function () { | ||
if (!_this9.mediaSource) return; | ||
Object.keys(this._sourceBuffer).forEach(function(k) { | ||
p = _this9._enqueueOp(k, function() { | ||
if (!_this9.mediaSource) | ||
return; | ||
var sb = _this9._sourceBuffer[k]; | ||
@@ -425,7 +313,7 @@ sb.remove(startTime, endTime); | ||
var _this10 = this; | ||
var p; | ||
Object.keys(this._sourceBuffer).forEach(function (k) { | ||
p = _this10._enqueueOp(k, function () { | ||
if (!_this10.mediaSource) return; | ||
Object.keys(this._sourceBuffer).forEach(function(k) { | ||
p = _this10._enqueueOp(k, function() { | ||
if (!_this10.mediaSource) | ||
return; | ||
var sb = _this10._sourceBuffer[k]; | ||
@@ -437,7 +325,2 @@ sb.remove(0, Buffer.end(Buffer.get(sb))); | ||
} | ||
/** | ||
* @param {EndOfStreamError} [reason] | ||
* @returns {Promise} | ||
*/ | ||
}, { | ||
@@ -447,8 +330,8 @@ key: "endOfStream", | ||
var _this11 = this; | ||
if (!this.mediaSource || this.mediaSource.readyState !== 'open') return Promise.resolve(); | ||
return this._enqueueBlockingOp(function () { | ||
if (!this.mediaSource || this.mediaSource.readyState !== "open") | ||
return Promise.resolve(); | ||
return this._enqueueBlockingOp(function() { | ||
var ms = _this11.mediaSource; | ||
if (!ms || ms.readyState !== 'open') return; | ||
if (!ms || ms.readyState !== "open") | ||
return; | ||
if (reason) { | ||
@@ -465,10 +348,6 @@ ms.endOfStream(reason); | ||
var ms = this.mediaSource; | ||
if (start < 0 || end < start || !(ms !== null && ms !== void 0 && ms.setLiveSeekableRange) || ms.readyState !== 'open') return; | ||
if (start < 0 || end < start || !(ms !== null && ms !== void 0 && ms.setLiveSeekableRange) || ms.readyState !== "open") | ||
return; | ||
ms.setLiveSeekableRange(start, end); | ||
} | ||
/** | ||
* @param { string } type | ||
* @return { TimeRanges | void } | ||
*/ | ||
}, { | ||
@@ -479,7 +358,2 @@ key: "buffered", | ||
} | ||
/** | ||
* @param { string } type | ||
* @return { number } | ||
*/ | ||
}, { | ||
@@ -490,7 +364,2 @@ key: "bufferStart", | ||
} | ||
/** | ||
* @param { string } type | ||
* @return { number } | ||
*/ | ||
}, { | ||
@@ -504,14 +373,13 @@ key: "bufferEnd", | ||
value: function _enqueueOp(type, exec) { | ||
if (!this.mediaSource) return Promise.resolve(); | ||
if (!this.mediaSource) | ||
return Promise.resolve(); | ||
var queue = this._queue[type] = this._queue[type] || []; | ||
var op = { | ||
exec: exec, | ||
exec, | ||
promise: createPublicPromise() | ||
}; | ||
queue.push(op); | ||
if (queue.length === 1) { | ||
this._startQueue(type); | ||
} | ||
return op.promise; | ||
@@ -521,8 +389,7 @@ } | ||
key: "_enqueueBlockingOp", | ||
value: function () { | ||
var _enqueueBlockingOp2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(exec) { | ||
value: function() { | ||
var _enqueueBlockingOp2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(exec) { | ||
var _this12 = this; | ||
var types, waiters; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) { | ||
@@ -535,8 +402,5 @@ switch (_context3.prev = _context3.next) { | ||
} | ||
return _context3.abrupt("return", Promise.resolve()); | ||
case 2: | ||
types = Object.keys(this._sourceBuffer); | ||
if (types.length) { | ||
@@ -546,8 +410,6 @@ _context3.next = 5; | ||
} | ||
return _context3.abrupt("return", exec()); | ||
case 5: | ||
waiters = []; | ||
types.forEach(function (t) { | ||
types.forEach(function(t) { | ||
var queue = _this12._queue[t]; | ||
@@ -557,3 +419,3 @@ var prom = createPublicPromise(); | ||
queue.push({ | ||
exec: function exec() { | ||
exec: function exec2() { | ||
return prom.resolve(); | ||
@@ -563,3 +425,2 @@ }, | ||
}); | ||
if (queue.length === 1) { | ||
@@ -569,11 +430,10 @@ _this12._startQueue(t); | ||
}); | ||
return _context3.abrupt("return", Promise.all(waiters).then(function () { | ||
return _context3.abrupt("return", Promise.all(waiters).then(function() { | ||
try { | ||
return exec(); | ||
} finally { | ||
types.forEach(function (t) { | ||
types.forEach(function(t) { | ||
var queue = _this12._queue[t]; | ||
var sb = _this12._sourceBuffer[t]; | ||
queue === null || queue === void 0 ? void 0 : queue.shift(); | ||
if (!sb || !sb.updating) { | ||
@@ -585,3 +445,2 @@ _this12._startQueue(t); | ||
})); | ||
case 8: | ||
@@ -594,7 +453,5 @@ case "end": | ||
})); | ||
function _enqueueBlockingOp(_x2) { | ||
return _enqueueBlockingOp2.apply(this, arguments); | ||
} | ||
return _enqueueBlockingOp; | ||
@@ -606,6 +463,4 @@ }() | ||
var queue = this._queue[type]; | ||
if (queue) { | ||
var op = queue[0]; | ||
if (op) { | ||
@@ -617,3 +472,2 @@ try { | ||
queue.shift(); | ||
this._startQueue(type); | ||
@@ -626,11 +480,6 @@ } | ||
key: "isSupported", | ||
value: | ||
/** | ||
* @param {string} [mime='video/mp4; codecs="avc1.42E01E,mp4a.40.2"'] | ||
* @returns {boolean} | ||
*/ | ||
function isSupported() { | ||
var mime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"'; | ||
if (!MediaSource) return false; | ||
value: function isSupported() { | ||
var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"'; | ||
if (!MediaSource) | ||
return false; | ||
try { | ||
@@ -643,10 +492,6 @@ return MediaSource.isTypeSupported(mime); | ||
}]); | ||
return MSE; | ||
return MSE2; | ||
}(); | ||
_defineProperty(MSE, "VIDEO", 'video'); | ||
_defineProperty(MSE, "AUDIO", 'audio'); | ||
_defineProperty(MSE, "VIDEO", "video"); | ||
_defineProperty(MSE, "AUDIO", "audio"); | ||
export { MSE, MSEError, MSEErrorType }; |
@@ -1,46 +0,32 @@ | ||
import 'core-js/modules/es.object.keys.js'; | ||
import 'core-js/modules/es.symbol.js'; | ||
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.object.get-own-property-descriptor.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import 'core-js/modules/es.object.get-own-property-descriptors.js'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import { LoaderType, ResponseType } from './types.js'; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
import { objectSpread2 as _objectSpread2 } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import { LoaderType, ResponseType } from "./types.js"; | ||
function getConfig(cfg) { | ||
return _objectSpread({ | ||
return _objectSpread2({ | ||
loaderType: LoaderType.FETCH, | ||
retry: 0, | ||
retryDelay: 0, | ||
// ms | ||
timeout: 0, | ||
request: null, | ||
// Request | ||
onTimeout: undefined, | ||
onProgress: undefined, | ||
onRetryError: undefined, | ||
transformRequest: undefined, | ||
transformResponse: undefined, | ||
transformError: undefined, | ||
onTimeout: void 0, | ||
onProgress: void 0, | ||
onRetryError: void 0, | ||
transformRequest: void 0, | ||
transformResponse: void 0, | ||
transformError: void 0, | ||
responseType: ResponseType.TEXT, | ||
range: undefined, | ||
url: '', | ||
params: undefined, | ||
method: 'GET', | ||
range: void 0, | ||
url: "", | ||
params: void 0, | ||
method: "GET", | ||
headers: {}, | ||
body: undefined, | ||
mode: undefined, | ||
credentials: undefined, | ||
cache: undefined, | ||
redirect: undefined, | ||
referrer: undefined, | ||
referrerPolicy: undefined, | ||
integrity: undefined | ||
body: void 0, | ||
mode: void 0, | ||
credentials: void 0, | ||
cache: void 0, | ||
redirect: void 0, | ||
referrer: void 0, | ||
referrerPolicy: void 0, | ||
integrity: void 0 | ||
}, cfg); | ||
} | ||
export { getConfig }; |
@@ -1,2 +0,2 @@ | ||
export class NetError extends Error { | ||
export class NetError { | ||
constructor(url: any, request: any, response: any, msg: any); | ||
@@ -3,0 +3,0 @@ retryCount: number; |
@@ -1,38 +0,16 @@ | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.reflect.construct.js'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized'; | ||
import _inherits from '@babel/runtime/helpers/inherits'; | ||
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn'; | ||
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf'; | ||
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import { LoaderType } from './types.js'; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var NetError = /*#__PURE__*/function (_Error) { | ||
_inherits(NetError, _Error); | ||
var _super = _createSuper(NetError); | ||
function NetError(url, request, response, msg) { | ||
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, wrapNativeSuper as _wrapNativeSuper } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.error.cause.js"; | ||
import { LoaderType } from "./types.js"; | ||
var NetError = /* @__PURE__ */ function(_Error) { | ||
_inherits(NetError2, _Error); | ||
var _super = _createSuper(NetError2); | ||
function NetError2(url, request, response, msg) { | ||
var _this; | ||
_classCallCheck(this, NetError); | ||
_classCallCheck(this, NetError2); | ||
_this = _super.call(this, msg); | ||
_defineProperty(_assertThisInitialized(_this), "retryCount", 0); | ||
_defineProperty(_assertThisInitialized(_this), "isTimeout", false); | ||
_defineProperty(_assertThisInitialized(_this), "loaderType", LoaderType.FETCH); | ||
_defineProperty(_assertThisInitialized(_this), "startTime", 0); | ||
_defineProperty(_assertThisInitialized(_this), "endTime", 0); | ||
_this.url = url; | ||
@@ -43,6 +21,4 @@ _this.request = request; | ||
} | ||
return _createClass(NetError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
return _createClass(NetError2); | ||
}(/* @__PURE__ */ _wrapNativeSuper(Error)); | ||
export { NetError }; |
@@ -27,13 +27,5 @@ export class FetchLoader { | ||
referrerPolicy: any; | ||
}): Promise<void | { | ||
data: any; | ||
response: any; | ||
contentLength: any; | ||
age: any; | ||
startTime: any; | ||
firstByteTime: any; | ||
endTime: number; | ||
}>; | ||
cancel(): Promise<void>; | ||
}): any; | ||
cancel(): any; | ||
_loadChunk(response: any, onProgress: any): void; | ||
} |
@@ -1,88 +0,61 @@ | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.uint8-array.js'; | ||
import 'core-js/modules/es.typed-array.copy-within.js'; | ||
import 'core-js/modules/es.typed-array.every.js'; | ||
import 'core-js/modules/es.typed-array.fill.js'; | ||
import 'core-js/modules/es.typed-array.filter.js'; | ||
import 'core-js/modules/es.typed-array.find.js'; | ||
import 'core-js/modules/es.typed-array.find-index.js'; | ||
import 'core-js/modules/es.typed-array.for-each.js'; | ||
import 'core-js/modules/es.typed-array.includes.js'; | ||
import 'core-js/modules/es.typed-array.index-of.js'; | ||
import 'core-js/modules/es.typed-array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.join.js'; | ||
import 'core-js/modules/es.typed-array.last-index-of.js'; | ||
import 'core-js/modules/es.typed-array.map.js'; | ||
import 'core-js/modules/es.typed-array.reduce.js'; | ||
import 'core-js/modules/es.typed-array.reduce-right.js'; | ||
import 'core-js/modules/es.typed-array.reverse.js'; | ||
import 'core-js/modules/es.typed-array.set.js'; | ||
import 'core-js/modules/es.typed-array.slice.js'; | ||
import 'core-js/modules/es.typed-array.some.js'; | ||
import 'core-js/modules/es.typed-array.sort.js'; | ||
import 'core-js/modules/es.typed-array.subarray.js'; | ||
import 'core-js/modules/es.typed-array.to-locale-string.js'; | ||
import 'core-js/modules/es.typed-array.to-string.js'; | ||
import { NetError } from './error.js'; | ||
import { setUrlParams, getRangeValue, createResponse } from './helper.js'; | ||
import { ResponseType } from './types.js'; | ||
var FetchLoader = /*#__PURE__*/function () { | ||
function FetchLoader() { | ||
_classCallCheck(this, FetchLoader); | ||
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.typed-array.uint8-array.js"; | ||
import "core-js/modules/es.typed-array.at.js"; | ||
import "core-js/modules/es.typed-array.copy-within.js"; | ||
import "core-js/modules/es.typed-array.every.js"; | ||
import "core-js/modules/es.typed-array.fill.js"; | ||
import "core-js/modules/es.typed-array.filter.js"; | ||
import "core-js/modules/es.typed-array.find.js"; | ||
import "core-js/modules/es.typed-array.find-index.js"; | ||
import "core-js/modules/es.typed-array.for-each.js"; | ||
import "core-js/modules/es.typed-array.includes.js"; | ||
import "core-js/modules/es.typed-array.index-of.js"; | ||
import "core-js/modules/es.typed-array.iterator.js"; | ||
import "core-js/modules/es.typed-array.join.js"; | ||
import "core-js/modules/es.typed-array.last-index-of.js"; | ||
import "core-js/modules/es.typed-array.map.js"; | ||
import "core-js/modules/es.typed-array.reduce.js"; | ||
import "core-js/modules/es.typed-array.reduce-right.js"; | ||
import "core-js/modules/es.typed-array.reverse.js"; | ||
import "core-js/modules/es.typed-array.set.js"; | ||
import "core-js/modules/es.typed-array.slice.js"; | ||
import "core-js/modules/es.typed-array.some.js"; | ||
import "core-js/modules/es.typed-array.sort.js"; | ||
import "core-js/modules/es.typed-array.subarray.js"; | ||
import "core-js/modules/es.typed-array.to-locale-string.js"; | ||
import "core-js/modules/es.typed-array.to-string.js"; | ||
import "core-js/modules/esnext.typed-array.find-last.js"; | ||
import "core-js/modules/esnext.typed-array.find-last-index.js"; | ||
import { NetError } from "./error.js"; | ||
import { setUrlParams, getRangeValue, createResponse } from "./helper.js"; | ||
import { ResponseType } from "./types.js"; | ||
var FetchLoader = /* @__PURE__ */ function() { | ||
function FetchLoader2() { | ||
_classCallCheck(this, FetchLoader2); | ||
_defineProperty(this, "_abortController", null); | ||
_defineProperty(this, "_timeoutTimer", null); | ||
_defineProperty(this, "_reader", null); | ||
_defineProperty(this, "_response", null); | ||
_defineProperty(this, "_aborted", false); | ||
} | ||
_createClass(FetchLoader, [{ | ||
_createClass(FetchLoader2, [{ | ||
key: "load", | ||
value: function load(_ref) { | ||
var _this$_abortControlle, | ||
_this = this; | ||
var url = _ref.url, | ||
timeout = _ref.timeout, | ||
responseType = _ref.responseType, | ||
onProgress = _ref.onProgress, | ||
onTimeout = _ref.onTimeout, | ||
range = _ref.range, | ||
transformResponse = _ref.transformResponse, | ||
request = _ref.request, | ||
params = _ref.params, | ||
method = _ref.method, | ||
headers = _ref.headers, | ||
body = _ref.body, | ||
mode = _ref.mode, | ||
credentials = _ref.credentials, | ||
cache = _ref.cache, | ||
redirect = _ref.redirect, | ||
referrer = _ref.referrer, | ||
referrerPolicy = _ref.referrerPolicy; | ||
var _this$_abortControlle, _this = this; | ||
var url = _ref.url, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, onTimeout = _ref.onTimeout, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, method = _ref.method, headers = _ref.headers, body = _ref.body, mode = _ref.mode, credentials = _ref.credentials, cache = _ref.cache, redirect = _ref.redirect, referrer = _ref.referrer, referrerPolicy = _ref.referrerPolicy; | ||
this._aborted = false; | ||
this._abortController = typeof AbortController !== 'undefined' && new AbortController(); | ||
this._abortController = typeof AbortController !== "undefined" && new AbortController(); | ||
var init = { | ||
method: method, | ||
headers: headers, | ||
body: body, | ||
mode: mode, | ||
credentials: credentials, | ||
cache: cache, | ||
redirect: redirect, | ||
referrer: referrer, | ||
referrerPolicy: referrerPolicy, | ||
method, | ||
headers, | ||
body, | ||
mode, | ||
credentials, | ||
cache, | ||
redirect, | ||
referrer, | ||
referrerPolicy, | ||
signal: (_this$_abortControlle = this._abortController) === null || _this$_abortControlle === void 0 ? void 0 : _this$_abortControlle.signal | ||
@@ -94,3 +67,2 @@ }; | ||
var rangeValue = getRangeValue(range); | ||
if (rangeValue) { | ||
@@ -102,5 +74,4 @@ if (request) { | ||
} | ||
if (headers instanceof Headers) { | ||
headers.append('Range', rangeValue); | ||
headers.append("Range", rangeValue); | ||
} else { | ||
@@ -110,9 +81,6 @@ headers.Range = rangeValue; | ||
} | ||
if (timeout) { | ||
this._timeoutTimer = setTimeout(function () { | ||
this._timeoutTimer = setTimeout(function() { | ||
isTimeout = true; | ||
_this.cancel(); | ||
if (onTimeout) { | ||
@@ -125,8 +93,7 @@ var error = new NetError(url, init); | ||
} | ||
var startTime = Date.now(); | ||
return fetch(request || url, request ? undefined : init).then( /*#__PURE__*/function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) { | ||
return fetch(request || url, request ? void 0 : init).then(/* @__PURE__ */ function() { | ||
var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(response) { | ||
var firstByteTime, data; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -137,3 +104,2 @@ switch (_context.prev = _context.next) { | ||
_this._response = response; | ||
if (!_this._aborted) { | ||
@@ -143,5 +109,3 @@ _context.next = 4; | ||
} | ||
return _context.abrupt("return"); | ||
case 4: | ||
@@ -151,3 +115,2 @@ if (transformResponse) { | ||
} | ||
if (response.ok) { | ||
@@ -157,8 +120,5 @@ _context.next = 7; | ||
} | ||
throw new NetError(url, init, response, 'bad network response'); | ||
throw new NetError(url, init, response, "bad network response"); | ||
case 7: | ||
firstByteTime = Date.now(); | ||
if (!(responseType === ResponseType.TEXT)) { | ||
@@ -168,6 +128,4 @@ _context.next = 14; | ||
} | ||
_context.next = 11; | ||
return response.text(); | ||
case 11: | ||
@@ -177,3 +135,2 @@ data = _context.sent; | ||
break; | ||
case 14: | ||
@@ -184,6 +141,4 @@ if (!(responseType === ResponseType.JSON)) { | ||
} | ||
_context.next = 17; | ||
return response.json(); | ||
case 17: | ||
@@ -193,3 +148,2 @@ data = _context.sent; | ||
break; | ||
case 20: | ||
@@ -200,19 +154,13 @@ if (!onProgress) { | ||
} | ||
_this._loadChunk(response, onProgress); | ||
_context.next = 28; | ||
break; | ||
case 24: | ||
_context.next = 26; | ||
return response.arrayBuffer(); | ||
case 26: | ||
data = _context.sent; | ||
data = new Uint8Array(data); | ||
case 28: | ||
return _context.abrupt("return", createResponse(data, response, response.headers.get('Content-Length'), response.headers.get('age'), startTime, firstByteTime)); | ||
return _context.abrupt("return", createResponse(data, response, response.headers.get("Content-Length"), response.headers.get("age"), startTime, firstByteTime)); | ||
case 29: | ||
@@ -225,9 +173,9 @@ case "end": | ||
})); | ||
return function (_x) { | ||
return function(_x) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()).catch(function (error) { | ||
}()).catch(function(error) { | ||
clearTimeout(_this._timeoutTimer); | ||
if (_this._aborted && !isTimeout) return; | ||
if (_this._aborted && !isTimeout) | ||
return; | ||
error = error instanceof NetError ? error : new NetError(url, init); | ||
@@ -242,5 +190,5 @@ error.startTime = startTime; | ||
key: "cancel", | ||
value: function () { | ||
var _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
value: function() { | ||
var _cancel = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
@@ -253,8 +201,5 @@ switch (_context2.prev = _context2.next) { | ||
} | ||
return _context2.abrupt("return"); | ||
case 2: | ||
this._aborted = true; | ||
if (!this._response) { | ||
@@ -264,5 +209,3 @@ _context2.next = 13; | ||
} | ||
_context2.prev = 4; | ||
if (!this._reader) { | ||
@@ -272,17 +215,12 @@ _context2.next = 8; | ||
} | ||
_context2.next = 8; | ||
return this._reader.cancel(); | ||
case 8: | ||
_context2.next = 12; | ||
break; | ||
case 10: | ||
_context2.prev = 10; | ||
_context2.t0 = _context2["catch"](4); | ||
case 12: | ||
this._response = this._reader = null; | ||
case 13: | ||
@@ -292,8 +230,6 @@ if (this._abortController) { | ||
this._abortController.abort(); | ||
} catch (error) {// ignore | ||
} catch (error) { | ||
} | ||
this._abortController = null; | ||
} | ||
case 14: | ||
@@ -306,7 +242,5 @@ case "end": | ||
})); | ||
function cancel() { | ||
return _cancel.apply(this, arguments); | ||
} | ||
return cancel; | ||
@@ -318,3 +252,2 @@ }() | ||
var _this2 = this; | ||
var reader = this._reader = response.body.getReader(); | ||
@@ -324,6 +257,5 @@ var data; | ||
var endTime; | ||
var pump = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
var pump = /* @__PURE__ */ function() { | ||
var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3() { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) { | ||
@@ -336,3 +268,2 @@ switch (_context3.prev = _context3.next) { | ||
return reader.read(); | ||
case 4: | ||
@@ -343,14 +274,11 @@ data = _context3.sent; | ||
break; | ||
case 8: | ||
_context3.prev = 8; | ||
_context3.t0 = _context3["catch"](1); | ||
// request aborted | ||
endTime = Date.now(); | ||
onProgress(undefined, true, { | ||
startTime: startTime, | ||
endTime: endTime | ||
onProgress(void 0, true, { | ||
startTime, | ||
endTime | ||
}, response); | ||
return _context3.abrupt("return"); | ||
case 13: | ||
@@ -361,19 +289,15 @@ if (!_this2._aborted) { | ||
} | ||
onProgress(undefined, true, { | ||
startTime: startTime, | ||
endTime: endTime | ||
onProgress(void 0, true, { | ||
startTime, | ||
endTime | ||
}, response); | ||
return _context3.abrupt("return"); | ||
case 16: | ||
onProgress(data.value, data.done, { | ||
startTime: startTime, | ||
endTime: endTime | ||
startTime, | ||
endTime | ||
}, response); | ||
if (!data.done) { | ||
pump(); | ||
} | ||
case 18: | ||
@@ -386,8 +310,6 @@ case "end": | ||
})); | ||
return function pump() { | ||
return function pump2() { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
pump(); | ||
@@ -398,9 +320,7 @@ } | ||
value: function isSupported() { | ||
return !!(typeof fetch !== 'undefined'); | ||
return !!(typeof fetch !== "undefined"); | ||
} | ||
}]); | ||
return FetchLoader; | ||
return FetchLoader2; | ||
}(); | ||
export { FetchLoader }; |
@@ -10,3 +10,3 @@ export function getRangeValue(value: any): string; | ||
firstByteTime: any; | ||
endTime: number; | ||
endTime: any; | ||
}; |
@@ -1,12 +0,12 @@ | ||
import 'core-js/modules/es.regexp.exec.js'; | ||
import 'core-js/modules/es.string.replace.js'; | ||
import 'core-js/modules/es.array.join.js'; | ||
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.array.map.js'; | ||
import 'core-js/modules/es.object.keys.js'; | ||
import 'core-js/modules/es.array.concat.js'; | ||
import 'core-js/modules/es.array.slice.js'; | ||
import { isDate, isObject } from '../is.js'; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import "core-js/modules/es.string.replace.js"; | ||
import "core-js/modules/es.array.join.js"; | ||
import "core-js/modules/es.array.filter.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.array.map.js"; | ||
import "core-js/modules/es.object.keys.js"; | ||
import "core-js/modules/es.json.stringify.js"; | ||
import "core-js/modules/es.array.concat.js"; | ||
import "core-js/modules/es.array.slice.js"; | ||
import { isDate, isObject } from "../is.js"; | ||
function getRangeValue(value) { | ||
@@ -16,27 +16,26 @@ if (!value || value[0] == null || value[0] === 0 && value[1] == null) { | ||
} | ||
var ret = 'bytes=' + value[0] + '-'; | ||
if (value[1]) ret += value[1]; | ||
var ret = "bytes=" + value[0] + "-"; | ||
if (value[1]) | ||
ret += value[1]; | ||
return ret; | ||
} | ||
function encode(val) { | ||
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); | ||
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); | ||
} | ||
function setUrlParams(url, params) { | ||
if (!url) return; | ||
if (!params) return url; | ||
if (!url) | ||
return; | ||
if (!params) | ||
return url; | ||
var v; | ||
var str = Object.keys(params).map(function (k) { | ||
var str = Object.keys(params).map(function(k) { | ||
v = params[k]; | ||
if (v == null) return; | ||
if (v == null) | ||
return; | ||
if (Array.isArray(v)) { | ||
k = k + '[]'; | ||
k = k + "[]"; | ||
} else { | ||
v = [v]; | ||
} | ||
return v.map(function (x) { | ||
return v.map(function(x) { | ||
if (isDate(x)) { | ||
@@ -47,17 +46,12 @@ x = x.toISOString(); | ||
} | ||
return "".concat(encode(k), "=").concat(encode(x)); | ||
}).join('&'); | ||
}).filter(Boolean).join('&'); | ||
}).join("&"); | ||
}).filter(Boolean).join("&"); | ||
if (str) { | ||
var hashIndex = url.indexOf('#'); | ||
var hashIndex = url.indexOf("#"); | ||
if (hashIndex !== -1) { | ||
url = url.slice(0, hashIndex); | ||
} | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + str; | ||
url += (url.indexOf("?") === -1 ? "?" : "&") + str; | ||
} | ||
return url; | ||
@@ -67,15 +61,15 @@ } | ||
age = age != null ? parseFloat(age) : null; | ||
contentLength = parseInt(contentLength || '0', 10); | ||
if (isNaN(contentLength)) contentLength = 0; | ||
contentLength = parseInt(contentLength || "0", 10); | ||
if (isNaN(contentLength)) | ||
contentLength = 0; | ||
return { | ||
data: data, | ||
response: response, | ||
contentLength: contentLength, | ||
age: age, | ||
startTime: startTime, | ||
firstByteTime: firstByteTime, | ||
data, | ||
response, | ||
contentLength, | ||
age, | ||
startTime, | ||
firstByteTime, | ||
endTime: Date.now() | ||
}; | ||
} | ||
export { createResponse, getRangeValue, setUrlParams }; |
@@ -10,4 +10,4 @@ export class NetLoader { | ||
isFetch(): boolean; | ||
load(url: any, config?: {}): Promise<any>; | ||
cancel(): Promise<void>; | ||
load(url: any, config?: {}): any; | ||
cancel(): any; | ||
_processTask(): void; | ||
@@ -14,0 +14,0 @@ } |
@@ -1,38 +0,27 @@ | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import 'core-js/modules/es.object.assign.js'; | ||
import 'core-js/modules/es.array.concat.js'; | ||
import 'core-js/modules/es.array.map.js'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import 'core-js/modules/es.string.iterator.js'; | ||
import 'core-js/modules/web.dom-collections.iterator.js'; | ||
import 'core-js/modules/es.promise.finally.js'; | ||
import 'core-js/modules/es.regexp.exec.js'; | ||
import { FetchLoader } from './fetch.js'; | ||
import { LoaderType } from './types.js'; | ||
export { LoaderType, ResponseType } from './types.js'; | ||
import { getConfig } from './config.js'; | ||
import { Task } from './task.js'; | ||
import { isPlainObject } from '../is.js'; | ||
import { sleep } from '../streaming-helper.js'; | ||
var NetLoader = /*#__PURE__*/function () { | ||
function NetLoader(cfg) { | ||
_classCallCheck(this, NetLoader); | ||
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.assign.js"; | ||
import "core-js/modules/es.array.concat.js"; | ||
import "core-js/modules/es.array.map.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
import "core-js/modules/web.dom-collections.iterator.js"; | ||
import "core-js/modules/es.promise.finally.js"; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import { FetchLoader } from "./fetch.js"; | ||
import { LoaderType } from "./types.js"; | ||
export { LoaderType, ResponseType } from "./types.js"; | ||
import { getConfig } from "./config.js"; | ||
import { Task } from "./task.js"; | ||
import { isPlainObject } from "../is.js"; | ||
import { sleep } from "../streaming-helper.js"; | ||
var NetLoader = /* @__PURE__ */ function() { | ||
function NetLoader2(cfg) { | ||
_classCallCheck(this, NetLoader2); | ||
_defineProperty(this, "type", LoaderType.FETCH); | ||
_defineProperty(this, "_queue", []); | ||
_defineProperty(this, "_alive", []); | ||
_defineProperty(this, "_currentTask", null); | ||
this._config = getConfig(cfg); | ||
if (this._config.loaderType === LoaderType.XHR || !FetchLoader.isSupported()) { | ||
@@ -42,4 +31,3 @@ this.type = LoaderType.XHR; | ||
} | ||
_createClass(NetLoader, [{ | ||
_createClass(NetLoader2, [{ | ||
key: "isFetch", | ||
@@ -52,5 +40,4 @@ value: function isFetch() { | ||
value: function load(url) { | ||
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (typeof url === 'string' || !url) { | ||
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; | ||
if (typeof url === "string" || !url) { | ||
config.url = url || config.url || this._config.url; | ||
@@ -60,20 +47,17 @@ } else { | ||
} | ||
config = Object.assign({}, this._config, config); | ||
if (config.params) config.params = Object.assign({}, config.params); | ||
if (config.headers && isPlainObject(config.headers)) config.headers = Object.assign({}, config.headers); | ||
if (config.body && isPlainObject(config.body)) config.body = Object.assign({}, config.body); | ||
if (config.params) | ||
config.params = Object.assign({}, config.params); | ||
if (config.headers && isPlainObject(config.headers)) | ||
config.headers = Object.assign({}, config.headers); | ||
if (config.body && isPlainObject(config.body)) | ||
config.body = Object.assign({}, config.body); | ||
if (config.transformRequest) { | ||
config = config.transformRequest(config) || config; | ||
} | ||
var task = new Task(this.type, config); | ||
this._queue.push(task); | ||
if (this._queue.length === 1) { | ||
this._processTask(); | ||
} | ||
return task.promise; | ||
@@ -83,19 +67,17 @@ } | ||
key: "cancel", | ||
value: function () { | ||
var _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
value: function() { | ||
var _cancel = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() { | ||
var cancels; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
cancels = this._queue.map(function (t) { | ||
cancels = this._queue.map(function(t) { | ||
return t.cancel(); | ||
}).concat(this._alive.map(function (t) { | ||
}).concat(this._alive.map(function(t) { | ||
return t.cancel(); | ||
})); | ||
if (this._currentTask) { | ||
cancels.push(this._currentTask.cancel()); | ||
} | ||
this._queue = []; | ||
@@ -105,7 +87,5 @@ this._alive = []; | ||
return Promise.all(cancels); | ||
case 6: | ||
_context.next = 8; | ||
return sleep(); | ||
case 8: | ||
@@ -118,7 +98,5 @@ case "end": | ||
})); | ||
function cancel() { | ||
return _cancel.apply(this, arguments); | ||
} | ||
return cancel; | ||
@@ -130,11 +108,10 @@ }() | ||
var _this = this; | ||
this._currentTask = this._queue.shift(); | ||
if (!this._currentTask) return; | ||
if (!this._currentTask) | ||
return; | ||
if (this._currentTask.alive) { | ||
this._alive.push(this._currentTask); | ||
} | ||
this._currentTask.exec().catch(function () {}).finally(function () { | ||
this._currentTask.exec().catch(function() { | ||
}).finally(function() { | ||
_this._processTask(); | ||
@@ -149,6 +126,4 @@ }); | ||
}]); | ||
return NetLoader; | ||
return NetLoader2; | ||
}(); | ||
export { NetLoader }; |
export class Task { | ||
constructor(type: any, config: any); | ||
promise: Promise<any>; | ||
promise: any; | ||
alive: boolean; | ||
@@ -11,6 +11,6 @@ _loaderType: any; | ||
_canceled: boolean; | ||
exec(): Promise<any>; | ||
cancel(): Promise<any>; | ||
exec(): any; | ||
cancel(): unknown; | ||
} | ||
import { FetchLoader } from "./fetch"; | ||
import { XhrLoader } from "./xhr"; |
@@ -1,16 +0,10 @@ | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import { FetchLoader } from './fetch.js'; | ||
import { XhrLoader } from './xhr.js'; | ||
import { LoaderType } from './types.js'; | ||
import { createPublicPromise } from '../utils.js'; | ||
import { createClass as _createClass, objectWithoutProperties as _objectWithoutProperties, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import { FetchLoader } from "./fetch.js"; | ||
import { XhrLoader } from "./xhr.js"; | ||
import { LoaderType } from "./types.js"; | ||
import { createPublicPromise } from "../utils.js"; | ||
var _excluded = ["retry", "retryDelay", "onRetryError", "transformError"]; | ||
var Task = /*#__PURE__*/function () { | ||
function Task(type, config) { | ||
_classCallCheck(this, Task); | ||
var Task = /* @__PURE__ */ function() { | ||
function Task2(type, config) { | ||
_classCallCheck(this, Task2); | ||
this.promise = createPublicPromise(); | ||
@@ -25,19 +19,11 @@ this.alive = !!config.onProgress; | ||
} | ||
_createClass(Task, [{ | ||
_createClass(Task2, [{ | ||
key: "exec", | ||
value: function exec() { | ||
var _this = this; | ||
var _this$_config = this._config, | ||
retry = _this$_config.retry, | ||
retryDelay = _this$_config.retryDelay, | ||
onRetryError = _this$_config.onRetryError, | ||
transformError = _this$_config.transformError, | ||
rest = _objectWithoutProperties(_this$_config, _excluded); | ||
var request = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
var _this$_config = this._config, retry = _this$_config.retry, retryDelay = _this$_config.retryDelay, onRetryError = _this$_config.onRetryError, transformError = _this$_config.transformError, rest = _objectWithoutProperties(_this$_config, _excluded); | ||
var request = /* @__PURE__ */ function() { | ||
var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() { | ||
var response, error; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -49,15 +35,10 @@ switch (_context.prev = _context.next) { | ||
return _this._loader.load(rest); | ||
case 3: | ||
response = _context.sent; | ||
_this.promise.resolve(response); | ||
_context.next = 22; | ||
break; | ||
case 7: | ||
_context.prev = 7; | ||
_context.t0 = _context["catch"](0); | ||
if (!_this._canceled) { | ||
@@ -67,5 +48,3 @@ _context.next = 11; | ||
} | ||
return _context.abrupt("return"); | ||
case 11: | ||
@@ -75,10 +54,8 @@ _context.t0.loaderType = _this._loaderType; | ||
error = _context.t0; | ||
if (transformError) { | ||
error = transformError(error) || error; | ||
} | ||
if (onRetryError && _this._retryCount > 0) onRetryError(error, _this._retryCount, retry); | ||
if (onRetryError && _this._retryCount > 0) | ||
onRetryError(error, _this._retryCount, retry); | ||
_this._retryCount++; | ||
if (!(_this._retryCount <= retry)) { | ||
@@ -88,10 +65,7 @@ _context.next = 21; | ||
} | ||
clearTimeout(_this._retryTimer); | ||
_this._retryTimer = setTimeout(request, retryDelay); | ||
return _context.abrupt("return"); | ||
case 21: | ||
_this.promise.reject(error); | ||
case 22: | ||
@@ -104,8 +78,6 @@ case "end": | ||
})); | ||
return function request() { | ||
return function request2() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
request(); | ||
@@ -116,5 +88,5 @@ return this.promise; | ||
key: "cancel", | ||
value: function () { | ||
var _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
value: function() { | ||
var _cancel = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
@@ -126,3 +98,2 @@ switch (_context2.prev = _context2.next) { | ||
return _context2.abrupt("return", this._loader.cancel()); | ||
case 3: | ||
@@ -135,14 +106,10 @@ case "end": | ||
})); | ||
function cancel() { | ||
return _cancel.apply(this, arguments); | ||
} | ||
return cancel; | ||
}() | ||
}]); | ||
return Task; | ||
return Task2; | ||
}(); | ||
export { Task }; |
var LoaderType = { | ||
FETCH: 'fetch', | ||
XHR: 'xhr' | ||
FETCH: "fetch", | ||
XHR: "xhr" | ||
}; | ||
var ResponseType = { | ||
ARRAY_BUFFER: 'arraybuffer', | ||
TEXT: 'text', | ||
JSON: 'json' | ||
ARRAY_BUFFER: "arraybuffer", | ||
TEXT: "text", | ||
JSON: "json" | ||
}; | ||
export { LoaderType, ResponseType }; |
@@ -6,5 +6,5 @@ export class XhrLoader { | ||
_timeoutTimer: any; | ||
load(req: any): Promise<any>; | ||
load(req: any): any; | ||
cancel(): any; | ||
_getHeaders(xhr: any): {}; | ||
} |
@@ -1,94 +0,64 @@ | ||
import 'core-js/modules/es.function.name.js'; | ||
import 'core-js/modules/es.array.from.js'; | ||
import 'core-js/modules/es.string.iterator.js'; | ||
import 'core-js/modules/es.symbol.js'; | ||
import 'core-js/modules/es.symbol.description.js'; | ||
import 'core-js/modules/es.symbol.iterator.js'; | ||
import 'core-js/modules/web.dom-collections.iterator.js'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import 'core-js/modules/es.object.keys.js'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.uint8-array.js'; | ||
import 'core-js/modules/es.typed-array.copy-within.js'; | ||
import 'core-js/modules/es.typed-array.every.js'; | ||
import 'core-js/modules/es.typed-array.fill.js'; | ||
import 'core-js/modules/es.typed-array.filter.js'; | ||
import 'core-js/modules/es.typed-array.find.js'; | ||
import 'core-js/modules/es.typed-array.find-index.js'; | ||
import 'core-js/modules/es.typed-array.for-each.js'; | ||
import 'core-js/modules/es.typed-array.includes.js'; | ||
import 'core-js/modules/es.typed-array.index-of.js'; | ||
import 'core-js/modules/es.typed-array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.join.js'; | ||
import 'core-js/modules/es.typed-array.last-index-of.js'; | ||
import 'core-js/modules/es.typed-array.map.js'; | ||
import 'core-js/modules/es.typed-array.reduce.js'; | ||
import 'core-js/modules/es.typed-array.reduce-right.js'; | ||
import 'core-js/modules/es.typed-array.reverse.js'; | ||
import 'core-js/modules/es.typed-array.set.js'; | ||
import 'core-js/modules/es.typed-array.slice.js'; | ||
import 'core-js/modules/es.typed-array.some.js'; | ||
import 'core-js/modules/es.typed-array.sort.js'; | ||
import 'core-js/modules/es.typed-array.subarray.js'; | ||
import 'core-js/modules/es.typed-array.to-locale-string.js'; | ||
import 'core-js/modules/es.typed-array.to-string.js'; | ||
import 'core-js/modules/es.regexp.exec.js'; | ||
import 'core-js/modules/es.string.split.js'; | ||
import 'core-js/modules/es.string.trim.js'; | ||
import 'core-js/modules/es.array.join.js'; | ||
import 'core-js/modules/es.array.slice.js'; | ||
import { NetError } from './error.js'; | ||
import { setUrlParams, getRangeValue, createResponse } from './helper.js'; | ||
import { ResponseType } from './types.js'; | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
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 XhrLoader = /*#__PURE__*/function () { | ||
function XhrLoader() { | ||
_classCallCheck(this, XhrLoader); | ||
import { createClass as _createClass, createForOfIteratorHelper as _createForOfIteratorHelper, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/web.dom-collections.for-each.js"; | ||
import "core-js/modules/es.object.keys.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.typed-array.uint8-array.js"; | ||
import "core-js/modules/es.typed-array.at.js"; | ||
import "core-js/modules/es.typed-array.copy-within.js"; | ||
import "core-js/modules/es.typed-array.every.js"; | ||
import "core-js/modules/es.typed-array.fill.js"; | ||
import "core-js/modules/es.typed-array.filter.js"; | ||
import "core-js/modules/es.typed-array.find.js"; | ||
import "core-js/modules/es.typed-array.find-index.js"; | ||
import "core-js/modules/es.typed-array.for-each.js"; | ||
import "core-js/modules/es.typed-array.includes.js"; | ||
import "core-js/modules/es.typed-array.index-of.js"; | ||
import "core-js/modules/es.typed-array.iterator.js"; | ||
import "core-js/modules/es.typed-array.join.js"; | ||
import "core-js/modules/es.typed-array.last-index-of.js"; | ||
import "core-js/modules/es.typed-array.map.js"; | ||
import "core-js/modules/es.typed-array.reduce.js"; | ||
import "core-js/modules/es.typed-array.reduce-right.js"; | ||
import "core-js/modules/es.typed-array.reverse.js"; | ||
import "core-js/modules/es.typed-array.set.js"; | ||
import "core-js/modules/es.typed-array.slice.js"; | ||
import "core-js/modules/es.typed-array.some.js"; | ||
import "core-js/modules/es.typed-array.sort.js"; | ||
import "core-js/modules/es.typed-array.subarray.js"; | ||
import "core-js/modules/es.typed-array.to-locale-string.js"; | ||
import "core-js/modules/es.typed-array.to-string.js"; | ||
import "core-js/modules/esnext.typed-array.find-last.js"; | ||
import "core-js/modules/esnext.typed-array.find-last-index.js"; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import "core-js/modules/es.string.split.js"; | ||
import "core-js/modules/es.string.trim.js"; | ||
import "core-js/modules/es.array.join.js"; | ||
import "core-js/modules/es.array.slice.js"; | ||
import { NetError } from "./error.js"; | ||
import { setUrlParams, getRangeValue, createResponse } from "./helper.js"; | ||
import { ResponseType } from "./types.js"; | ||
var XhrLoader = /* @__PURE__ */ function() { | ||
function XhrLoader2() { | ||
_classCallCheck(this, XhrLoader2); | ||
_defineProperty(this, "_xhr", null); | ||
_defineProperty(this, "_aborted", false); | ||
_defineProperty(this, "_timeoutTimer", null); | ||
} | ||
_createClass(XhrLoader, [{ | ||
_createClass(XhrLoader2, [{ | ||
key: "load", | ||
value: function load(req) { | ||
var _this = this; | ||
clearTimeout(this._timeoutTimer); | ||
var url = req.url, | ||
params = req.params, | ||
timeout = req.timeout, | ||
responseType = req.responseType, | ||
onTimeout = req.onTimeout, | ||
transformResponse = req.transformResponse, | ||
onProgress = req.onProgress, | ||
method = req.method, | ||
credentials = req.credentials, | ||
body = req.body, | ||
headers = req.headers, | ||
range = req.range, | ||
request = req.request; | ||
var url = req.url, params = req.params, timeout = req.timeout, responseType = req.responseType, onTimeout = req.onTimeout, transformResponse = req.transformResponse, onProgress = req.onProgress, method = req.method, credentials = req.credentials, body = req.body, headers = req.headers, range = req.range, request = req.request; | ||
var isTimeout = false; | ||
url = setUrlParams(url, params); | ||
var startTime = Date.now(); | ||
return new Promise(function (resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
var xhr = _this._xhr = new XMLHttpRequest(); | ||
xhr.open(method || 'GET', url, true); | ||
xhr.open(method || "GET", url, true); | ||
xhr.responseType = responseType; | ||
xhr.withCredentials = credentials === 'include' || credentials === 'same-origin'; | ||
xhr.withCredentials = credentials === "include" || credentials === "same-origin"; | ||
var rangeValue = getRangeValue(range); | ||
if (rangeValue) { | ||
@@ -98,15 +68,11 @@ headers = headers || {}; | ||
} | ||
if (headers) { | ||
Object.keys(headers).forEach(function (k) { | ||
Object.keys(headers).forEach(function(k) { | ||
xhr.setRequestHeader(k, headers[k]); | ||
}); | ||
} | ||
if (timeout) { | ||
_this._timeoutTimer = setTimeout(function () { | ||
_this._timeoutTimer = setTimeout(function() { | ||
isTimeout = true; | ||
_this.cancel(); | ||
if (onTimeout) { | ||
@@ -119,19 +85,17 @@ var error = new NetError(url, request); | ||
} | ||
xhr.onerror = function (event) { | ||
xhr.onerror = function(event) { | ||
return reject(event); | ||
}; | ||
xhr.onreadystatechange = function () { | ||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState >= 2) { | ||
clearTimeout(_this._timeoutTimer); | ||
var firstByteTime = Date.now(); | ||
if (xhr.readyState === 4) { | ||
xhr.onreadystatechange = null; | ||
if (_this._aborted) return; | ||
if (_this._aborted) | ||
return; | ||
var status = xhr.status; | ||
var response = { | ||
ok: status >= 200 && status < 300, | ||
status: status, | ||
status, | ||
statusText: xhr.statusText, | ||
@@ -142,30 +106,25 @@ url: xhr.responseURL, | ||
}; | ||
if (transformResponse) { | ||
response = transformResponse(response, url) || response; | ||
} | ||
if (!response.ok) { | ||
return reject(new NetError(url, request, response, 'bad network response')); | ||
return reject(new NetError(url, request, response, "bad network response")); | ||
} | ||
var isArraybuffer = xhr.responseType === ResponseType.ARRAY_BUFFER; | ||
var data = isArraybuffer ? new Uint8Array(xhr.response) : xhr.response; | ||
if (onProgress) { | ||
onProgress(isArraybuffer ? data : undefined, true, { | ||
startTime: startTime, | ||
onProgress(isArraybuffer ? data : void 0, true, { | ||
startTime, | ||
endTime: Date.now() | ||
}, response); | ||
} | ||
resolve(createResponse(data, response, response.headers['content-length'], response.headers.age, startTime, firstByteTime)); | ||
resolve(createResponse(data, response, response.headers["content-length"], response.headers.age, startTime, firstByteTime)); | ||
} | ||
} | ||
}; | ||
xhr.send(body); | ||
}).catch(function (error) { | ||
}).catch(function(error) { | ||
clearTimeout(_this._timeoutTimer); | ||
if (_this._aborted && !isTimeout) return; | ||
if (_this._aborted && !isTimeout) | ||
return; | ||
error = error instanceof NetError ? error : new NetError(url, request); | ||
@@ -181,5 +140,5 @@ error.startTime = startTime; | ||
value: function cancel() { | ||
if (this._aborted) return; | ||
if (this._aborted) | ||
return; | ||
this._aborted = true; | ||
if (this._xhr) { | ||
@@ -192,13 +151,10 @@ return this._xhr.cancel(); | ||
value: function _getHeaders(xhr) { | ||
var headerLines = xhr.getAllResponseHeaders().trim().split('\r\n'); | ||
var headerLines = xhr.getAllResponseHeaders().trim().split("\r\n"); | ||
var headers = {}; | ||
var _iterator = _createForOfIteratorHelper(headerLines), | ||
_step; | ||
var _iterator = _createForOfIteratorHelper(headerLines), _step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
for (_iterator.s(); !(_step = _iterator.n()).done; ) { | ||
var header = _step.value; | ||
var parts = header.split(': '); | ||
headers[parts[0].toLowerCase()] = parts.slice(1).join(': '); | ||
var parts = header.split(": "); | ||
headers[parts[0].toLowerCase()] = parts.slice(1).join(": "); | ||
} | ||
@@ -210,3 +166,2 @@ } catch (err) { | ||
} | ||
return headers; | ||
@@ -217,9 +172,7 @@ } | ||
value: function isSupported() { | ||
return typeof XMLHttpRequest !== 'undefined'; | ||
return typeof XMLHttpRequest !== "undefined"; | ||
} | ||
}]); | ||
return XhrLoader; | ||
return XhrLoader2; | ||
}(); | ||
export { XhrLoader }; |
@@ -1,24 +0,16 @@ | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import 'core-js/modules/es.array.slice.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
var BandwidthService = /*#__PURE__*/function () { | ||
function BandwidthService() { | ||
_classCallCheck(this, BandwidthService); | ||
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.array.slice.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
var BandwidthService = /* @__PURE__ */ function() { | ||
function BandwidthService2() { | ||
_classCallCheck(this, BandwidthService2); | ||
_defineProperty(this, "_chunkSpeeds", []); | ||
_defineProperty(this, "_speeds", []); | ||
} | ||
_createClass(BandwidthService, [{ | ||
_createClass(BandwidthService2, [{ | ||
key: "addRecord", | ||
value: // bps | ||
function addRecord(totalByte, ms) { | ||
if (!totalByte || !ms) return; | ||
this._speeds.push(8000 * totalByte / ms); | ||
value: function addRecord(totalByte, ms) { | ||
if (!totalByte || !ms) | ||
return; | ||
this._speeds.push(8e3 * totalByte / ms); | ||
this._speeds = this._speeds.slice(-3); | ||
@@ -29,6 +21,5 @@ } | ||
value: function addChunkRecord(totalByte, ms) { | ||
if (!totalByte || !ms) return; | ||
this._chunkSpeeds.push(8000 * totalByte / ms); | ||
if (!totalByte || !ms) | ||
return; | ||
this._chunkSpeeds.push(8e3 * totalByte / ms); | ||
this._chunkSpeeds = this._chunkSpeeds.slice(-10); | ||
@@ -39,11 +30,10 @@ } | ||
value: function getAvgSpeed() { | ||
if (!this._chunkSpeeds.length && !this._speeds.length) return 0; | ||
if (!this._chunkSpeeds.length && !this._speeds.length) | ||
return 0; | ||
if (this._speeds.length) { | ||
return this._speeds.reduce(function (a, c) { | ||
return this._speeds.reduce(function(a, c) { | ||
return a += c; | ||
}) / this._speeds.length; | ||
} | ||
return this._chunkSpeeds.reduce(function (a, c) { | ||
return this._chunkSpeeds.reduce(function(a, c) { | ||
return a += c; | ||
@@ -55,8 +45,7 @@ }) / this._chunkSpeeds.length; | ||
value: function getLatestSpeed() { | ||
if (!this._chunkSpeeds.length && !this._speeds.length) return 0; | ||
if (!this._chunkSpeeds.length && !this._speeds.length) | ||
return 0; | ||
if (this._speeds.length) { | ||
return this._speeds[this._speeds.length - 1]; | ||
} | ||
return this._chunkSpeeds[this._chunkSpeeds.length - 1]; | ||
@@ -71,6 +60,4 @@ } | ||
}]); | ||
return BandwidthService; | ||
return BandwidthService2; | ||
}(); | ||
export { BandwidthService }; |
@@ -1,27 +0,22 @@ | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import { Buffer } from '../buffer.js'; | ||
var GapService = /*#__PURE__*/function () { | ||
function GapService() { | ||
_classCallCheck(this, GapService); | ||
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import { Buffer } from "../buffer.js"; | ||
var GapService = /* @__PURE__ */ function() { | ||
function GapService2() { | ||
_classCallCheck(this, GapService2); | ||
_defineProperty(this, "_prevCurrentTime", 0); | ||
} | ||
_createClass(GapService, [{ | ||
_createClass(GapService2, [{ | ||
key: "do", | ||
value: function _do(media) { | ||
var maxJumpDistance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3; | ||
var isLive = arguments.length > 2 ? arguments[2] : undefined; | ||
var seekThreshold = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
if (!media) return; | ||
var maxJumpDistance = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 3; | ||
var isLive = arguments.length > 2 ? arguments[2] : void 0; | ||
var seekThreshold = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1; | ||
if (!media) | ||
return; | ||
var currentTime = media.currentTime; | ||
var jumpTo = 0; | ||
if (this._prevCurrentTime === currentTime) { | ||
var info = Buffer.info(Buffer.get(media), currentTime); | ||
if (!info.buffers.length) return; | ||
if (!info.buffers.length) | ||
return; | ||
if (isLive && info.nextStart || info.nextStart && info.nextStart - currentTime < maxJumpDistance) { | ||
@@ -33,5 +28,3 @@ jumpTo = info.nextStart + 0.1; | ||
} | ||
this._prevCurrentTime = currentTime; | ||
if (jumpTo && currentTime !== jumpTo) { | ||
@@ -42,6 +35,4 @@ media.currentTime = jumpTo; | ||
}]); | ||
return GapService; | ||
return GapService2; | ||
}(); | ||
export { GapService }; |
export class SeiService { | ||
constructor(emitter: any); | ||
_seiSet: Set<any>; | ||
_seiSet: any; | ||
emitter: any; | ||
@@ -5,0 +5,0 @@ throw(currentTime: any): void; |
@@ -1,37 +0,30 @@ | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.set.js'; | ||
import 'core-js/modules/es.string.iterator.js'; | ||
import 'core-js/modules/web.dom-collections.iterator.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import { EVENT } from '../event.js'; | ||
var SeiService = /*#__PURE__*/function () { | ||
function SeiService(emitter) { | ||
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.set.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
import "core-js/modules/web.dom-collections.iterator.js"; | ||
import "core-js/modules/web.dom-collections.for-each.js"; | ||
import { EVENT } from "../event.js"; | ||
var SeiService = /* @__PURE__ */ function() { | ||
function SeiService2(emitter) { | ||
var _this = this; | ||
_classCallCheck(this, SeiService); | ||
_defineProperty(this, "_seiSet", new Set()); | ||
_classCallCheck(this, SeiService2); | ||
_defineProperty(this, "_seiSet", /* @__PURE__ */ new Set()); | ||
this.emitter = emitter; | ||
emitter.on(EVENT.SEI, function (sei) { | ||
if (sei) _this._seiSet.add(sei); | ||
emitter.on(EVENT.SEI, function(sei) { | ||
if (sei) | ||
_this._seiSet.add(sei); | ||
}); | ||
} | ||
_createClass(SeiService, [{ | ||
_createClass(SeiService2, [{ | ||
key: "throw", | ||
value: function _throw(currentTime) { | ||
var _this2 = this; | ||
if (currentTime == null || !this._seiSet.size) return; | ||
if (currentTime == null || !this._seiSet.size) | ||
return; | ||
var min = currentTime - 0.2; | ||
var max = currentTime + 0.2; | ||
var toThrow = []; | ||
this._seiSet.forEach(function (sei) { | ||
this._seiSet.forEach(function(sei) { | ||
if (sei.time >= min && sei.time <= max) { | ||
@@ -41,6 +34,4 @@ toThrow.push(sei); | ||
}); | ||
toThrow.forEach(function (sei) { | ||
toThrow.forEach(function(sei) { | ||
_this2._seiSet.delete(sei); | ||
_this2.emitter.emit(EVENT.SEI_IN_TIME, sei); | ||
@@ -55,6 +46,4 @@ }); | ||
}]); | ||
return SeiService; | ||
return SeiService2; | ||
}(); | ||
export { SeiService }; |
@@ -15,3 +15,3 @@ export function isMediaPlaying(media: any): boolean; | ||
*/ | ||
export function concatUint8Array(...arr: Array<Uint8Array>): Uint8Array; | ||
export function sleep(t?: number): Promise<any>; | ||
export function concatUint8Array(...arr: Array<Uint8Array>): any; | ||
export function sleep(t?: number): any; |
@@ -1,31 +0,33 @@ | ||
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.uint8-array.js'; | ||
import 'core-js/modules/es.typed-array.copy-within.js'; | ||
import 'core-js/modules/es.typed-array.every.js'; | ||
import 'core-js/modules/es.typed-array.fill.js'; | ||
import 'core-js/modules/es.typed-array.filter.js'; | ||
import 'core-js/modules/es.typed-array.find.js'; | ||
import 'core-js/modules/es.typed-array.find-index.js'; | ||
import 'core-js/modules/es.typed-array.for-each.js'; | ||
import 'core-js/modules/es.typed-array.includes.js'; | ||
import 'core-js/modules/es.typed-array.index-of.js'; | ||
import 'core-js/modules/es.typed-array.iterator.js'; | ||
import 'core-js/modules/es.typed-array.join.js'; | ||
import 'core-js/modules/es.typed-array.last-index-of.js'; | ||
import 'core-js/modules/es.typed-array.map.js'; | ||
import 'core-js/modules/es.typed-array.reduce.js'; | ||
import 'core-js/modules/es.typed-array.reduce-right.js'; | ||
import 'core-js/modules/es.typed-array.reverse.js'; | ||
import 'core-js/modules/es.typed-array.set.js'; | ||
import 'core-js/modules/es.typed-array.slice.js'; | ||
import 'core-js/modules/es.typed-array.some.js'; | ||
import 'core-js/modules/es.typed-array.sort.js'; | ||
import 'core-js/modules/es.typed-array.subarray.js'; | ||
import 'core-js/modules/es.typed-array.to-locale-string.js'; | ||
import 'core-js/modules/es.typed-array.to-string.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import "core-js/modules/es.array.filter.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.typed-array.uint8-array.js"; | ||
import "core-js/modules/es.typed-array.at.js"; | ||
import "core-js/modules/es.typed-array.copy-within.js"; | ||
import "core-js/modules/es.typed-array.every.js"; | ||
import "core-js/modules/es.typed-array.fill.js"; | ||
import "core-js/modules/es.typed-array.filter.js"; | ||
import "core-js/modules/es.typed-array.find.js"; | ||
import "core-js/modules/es.typed-array.find-index.js"; | ||
import "core-js/modules/es.typed-array.for-each.js"; | ||
import "core-js/modules/es.typed-array.includes.js"; | ||
import "core-js/modules/es.typed-array.index-of.js"; | ||
import "core-js/modules/es.typed-array.iterator.js"; | ||
import "core-js/modules/es.typed-array.join.js"; | ||
import "core-js/modules/es.typed-array.last-index-of.js"; | ||
import "core-js/modules/es.typed-array.map.js"; | ||
import "core-js/modules/es.typed-array.reduce.js"; | ||
import "core-js/modules/es.typed-array.reduce-right.js"; | ||
import "core-js/modules/es.typed-array.reverse.js"; | ||
import "core-js/modules/es.typed-array.set.js"; | ||
import "core-js/modules/es.typed-array.slice.js"; | ||
import "core-js/modules/es.typed-array.some.js"; | ||
import "core-js/modules/es.typed-array.sort.js"; | ||
import "core-js/modules/es.typed-array.subarray.js"; | ||
import "core-js/modules/es.typed-array.to-locale-string.js"; | ||
import "core-js/modules/es.typed-array.to-string.js"; | ||
import "core-js/modules/esnext.typed-array.find-last.js"; | ||
import "core-js/modules/esnext.typed-array.find-last-index.js"; | ||
import "core-js/modules/web.dom-collections.for-each.js"; | ||
import "core-js/modules/es.promise.js"; | ||
function isMediaPlaying(media) { | ||
@@ -35,5 +37,5 @@ return media && !media.paused && !media.ended && media.playbackRate !== 0 && media.readyState !== 0; | ||
function getVideoPlaybackQuality(video) { | ||
if (!video) return {}; | ||
if (typeof video.getVideoPlaybackQuality === 'function') { | ||
if (!video) | ||
return {}; | ||
if (typeof video.getVideoPlaybackQuality === "function") { | ||
var info = video.getVideoPlaybackQuality(); | ||
@@ -46,3 +48,2 @@ return { | ||
} | ||
return { | ||
@@ -54,7 +55,2 @@ droppedVideoFrames: video.webkitDroppedFrameCount, | ||
} | ||
/** | ||
* @param {Array.<Uint8Array>} arr | ||
* @returns | ||
*/ | ||
function concatUint8Array() { | ||
@@ -64,10 +60,10 @@ for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) { | ||
} | ||
arr = arr.filter(Boolean); | ||
if (arr.length < 2) return arr[0]; | ||
var data = new Uint8Array(arr.reduce(function (p, c) { | ||
if (arr.length < 2) | ||
return arr[0]; | ||
var data = new Uint8Array(arr.reduce(function(p, c) { | ||
return p + c.byteLength; | ||
}, 0)); | ||
var prevLen = 0; | ||
arr.forEach(function (d) { | ||
arr.forEach(function(d) { | ||
data.set(d, prevLen); | ||
@@ -79,8 +75,7 @@ prevLen += d.byteLength; | ||
function sleep() { | ||
var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
return new Promise(function (resolve) { | ||
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; | ||
return new Promise(function(resolve) { | ||
return setTimeout(resolve, t); | ||
}); | ||
} | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, sleep }; |
@@ -1,1 +0,1 @@ | ||
export function createPublicPromise(): Promise<any>; | ||
export function createPublicPromise(): any; |
@@ -1,7 +0,6 @@ | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.promise.js"; | ||
function createPublicPromise() { | ||
var res, rej; | ||
var promise = new Promise(function (resolve, reject) { | ||
var promise = new Promise(function(resolve, reject) { | ||
res = resolve; | ||
@@ -11,16 +10,12 @@ rej = reject; | ||
promise.used = false; | ||
promise.resolve = function () { | ||
promise.resolve = function() { | ||
promise.used = true; | ||
return res.apply(void 0, arguments); | ||
}; | ||
promise.reject = function () { | ||
promise.reject = function() { | ||
promise.used = true; | ||
return rej.apply(void 0, arguments); | ||
}; | ||
return promise; | ||
} | ||
export { createPublicPromise }; |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.0-next.9", | ||
"version": "3.0.0-next.10", | ||
"main": "dist/index.min.js", | ||
@@ -8,3 +8,5 @@ "module": "es/index.js", | ||
"sideEffects": false, | ||
"umdName": "XGPlayerStreamingShared", | ||
"libd": { | ||
"umdName": "XGPlayerStreamingShared" | ||
}, | ||
"files": [ | ||
@@ -16,3 +18,4 @@ "dist", | ||
"registry": "https://registry.npmjs.org/", | ||
"access": "public" | ||
"access": "public", | ||
"tag": "next" | ||
}, | ||
@@ -22,7 +25,3 @@ "license": "MIT", | ||
"dist" | ||
], | ||
"dependencies": { | ||
"core-js": "3", | ||
"@babel/runtime": "^7.15.3" | ||
} | ||
] | ||
} |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
772863
0
48
3537
5
- Removed@babel/runtime@^7.15.3
- Removedcore-js@3
- Removed@babel/runtime@7.24.7(transitive)
- Removedcore-js@3.37.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)