Socket
Socket
Sign inDemoInstall

xgplayer-streaming-shared

Package Overview
Dependencies
1
Maintainers
5
Versions
183
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0-alpha.5-21 to 3.0.0-alpha.5-22

dist/index.min.js

27

es/_virtual/_rollupPluginBabelHelpers.js

@@ -557,2 +557,27 @@ function ownKeys(object, enumerableOnly) {

}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null)
break;
}
return object;
}
function _get() {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get.bind();
} else {
_get = function _get2(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base)
return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
}
return desc.value;
};
}
return _get.apply(this, arguments);
}
function _unsupportedIterableToArray(o, minLen) {

@@ -632,2 +657,2 @@ if (!o)

}
export { _arrayLikeToArray as arrayLikeToArray, _assertThisInitialized as assertThisInitialized, _asyncToGenerator as asyncToGenerator, _classCallCheck as classCallCheck, _construct as construct, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _createSuper as createSuper, _defineProperty as defineProperty, _getPrototypeOf as getPrototypeOf, _inherits as inherits, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _possibleConstructorReturn as possibleConstructorReturn, _regeneratorRuntime as regeneratorRuntime, _setPrototypeOf as setPrototypeOf, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray, _wrapNativeSuper as wrapNativeSuper };
export { _arrayLikeToArray as arrayLikeToArray, _assertThisInitialized as assertThisInitialized, _asyncToGenerator as asyncToGenerator, _classCallCheck as classCallCheck, _construct as construct, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _createSuper as createSuper, _defineProperty as defineProperty, _get as get, _getPrototypeOf as getPrototypeOf, _inherits as inherits, _isNativeFunction as isNativeFunction, _isNativeReflectConstruct as isNativeReflectConstruct, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _possibleConstructorReturn as possibleConstructorReturn, _regeneratorRuntime as regeneratorRuntime, _setPrototypeOf as setPrototypeOf, _superPropBase as superPropBase, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray, _wrapNativeSuper as wrapNativeSuper };

1

es/buffer.js
import { createClass as _createClass, classCallCheck as _classCallCheck } from "./_virtual/_rollupPluginBabelHelpers.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.object.to-string.js";

@@ -4,0 +3,0 @@ var Buffer = /* @__PURE__ */ function() {

@@ -18,2 +18,3 @@ export namespace ERR {

const MSE_OTHER: string;
const MSE_FULL: string;
const OPTION: string;

@@ -31,2 +32,3 @@ }

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -40,2 +42,3 @@ FLV: number;

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -49,2 +52,3 @@ FMP4: number;

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -54,2 +58,3 @@ MSE_ADD_SB: number;

MSE_OTHER: number;
MSE_FULL: number;
HLS?: undefined;

@@ -56,0 +61,0 @@ FLV?: undefined;

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;

@@ -21,2 +20,3 @@ var ERR = {

MSE_OTHER: "MSE_OTHER",
MSE_FULL: "MSE_FULL",
OPTION: "OPTION"

@@ -38,3 +38,4 @@ }

MSE_APPEND_BUFFER: 5201,
MSE_OTHER: 5202
MSE_OTHER: 5202,
MSE_FULL: 5203
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8e3), _ERR_CODE);

@@ -41,0 +42,0 @@ var StreamingError = /* @__PURE__ */ function(_Error) {

@@ -66,2 +66,3 @@ declare var _default: {

MSE_OTHER: string;
MSE_FULL: string;
OPTION: string;

@@ -79,2 +80,3 @@ };

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -88,2 +90,3 @@ FLV: number;

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -97,2 +100,3 @@ FMP4: number;

MSE_OTHER?: undefined;
MSE_FULL?: undefined;
} | {

@@ -102,2 +106,3 @@ MSE_ADD_SB: number;

MSE_OTHER: number;
MSE_FULL: number;
HLS?: undefined;

@@ -104,0 +109,0 @@ FLV?: undefined;

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";
import "core-js/modules/esnext.array.group.js";
import { nowTime } from "./utils.js";
var Logger = /* @__PURE__ */ function() {

@@ -20,3 +20,3 @@ function Logger2(name) {

}
(_console = console).debug.apply(_console, [this._prefix].concat(args));
(_console = console).debug.apply(_console, [this._prefix, nowTime()].concat(args));
}

@@ -32,3 +32,3 @@ }, {

}
(_console2 = console).log.apply(_console2, [this._prefix].concat(args));
(_console2 = console).log.apply(_console2, [this._prefix, nowTime()].concat(args));
}

@@ -44,3 +44,3 @@ }, {

}
(_console3 = console).warn.apply(_console3, [this._prefix].concat(args));
(_console3 = console).warn.apply(_console3, [this._prefix, nowTime()].concat(args));
}

@@ -56,3 +56,3 @@ }, {

}
(_console4 = console).error.apply(_console4, [this._prefix].concat(args));
(_console4 = console).error.apply(_console4, [this._prefix, nowTime()].concat(args));
}

@@ -59,0 +59,0 @@ }, {

@@ -17,2 +17,5 @@ export type MSEErrorType = string;

static AUDIO: string;
static getDefaultConfig(): {
openLog: boolean;
};
/**

@@ -26,3 +29,3 @@ * @param {string} [mime='video/mp4; codecs="avc1.42E01E,mp4a.40.2"']

*/
constructor(media?: HTMLMediaElement);
constructor(media?: HTMLMediaElement, config: any);
/** @type { HTMLMediaElement | null } */

@@ -35,4 +38,12 @@ media: HTMLMediaElement | null;

_sourceBuffer: any;
_mseFullFlag: {};
_st: number;
_opst: number;
_logger: any;
_config: any;
_url: any;
get isOpened(): boolean;
get url(): any;
get duration(): any;
isFull(type: any): any;
/**

@@ -74,3 +85,3 @@ * @param { number } duration

*/
append(type: string, buffer: BufferSource): Promise;
append(type: string, buffer: BufferSource, context: any): Promise;
/**

@@ -82,5 +93,6 @@ * @param { string } type

*/
remove(type: string, startTime: number, endTime: number): Promise;
remove(type: string, startTime: number, endTime: number, context: any): Promise;
clearBuffer(startTime: any, endTime: any): undefined;
clearAllBuffer(): undefined;
clearOpQueues(type: any): void;
/**

@@ -107,3 +119,3 @@ * @param {EndOfStreamError} [reason]

bufferEnd(type: string): number;
_enqueueOp(type: any, exec: any): any;
_enqueueOp(type: any, exec: any, opName: any, context: any, isInsertHead: any): any;
_enqueueBlockingOp(exec: any): unknown;

@@ -110,0 +122,0 @@ _startQueue(type: any): void;

import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, 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.object.assign.js";
import "core-js/modules/es.array.iterator.js";

@@ -12,8 +12,10 @@ import "core-js/modules/es.object.to-string.js";

import "core-js/modules/es.promise.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.array.slice.js";
import "core-js/modules/es.array.splice.js";
import "core-js/modules/es.regexp.exec.js";
import { createPublicPromise } from "./utils.js";
import { createPublicPromise, nowTime } from "./utils.js";
import { Buffer } from "./buffer.js";
import { StreamingError, ERR } from "./error.js";
import { isBrowser } from "./env.js";
import { Logger } from "./logger.js";
function getMediaSource() {

@@ -29,2 +31,6 @@ try {

};
var OP_NAME = {
APPEND: "appendBuffer",
REMOVE: "removeBuffer"
};
var MSEError = /* @__PURE__ */ function(_Error) {

@@ -44,3 +50,3 @@ _inherits(MSEError2, _Error);

var MSE = /* @__PURE__ */ function() {
function MSE2(media) {
function MSE2(media, config) {
var _this2 = this;

@@ -53,2 +59,8 @@ _classCallCheck(this, MSE2);

_defineProperty(this, "_sourceBuffer", /* @__PURE__ */ Object.create(null));
_defineProperty(this, "_mseFullFlag", {});
_defineProperty(this, "_st", 0);
_defineProperty(this, "_opst", 0);
_defineProperty(this, "_logger", null);
_defineProperty(this, "_config", null);
_defineProperty(this, "_url", null);
_defineProperty(this, "_onSBUpdateEnd", function(type) {

@@ -59,3 +71,9 @@ var queue = _this2._queue[type];

if (op) {
op.promise.resolve();
var costtime = nowTime() - _this2._opst;
_this2._logger.debug("UpdateEnd", op.opName, costtime, op.context);
op.promise.resolve({
name: op.opName,
context: op.context,
costtime
});
_this2._startQueue(type);

@@ -70,2 +88,3 @@ }

if (op) {
_this2._logger.error("UpdateError", type, op.opName, op.context);
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_APPEND_BUFFER, event));

@@ -75,4 +94,9 @@ }

});
this._config = Object.assign(MSE2.getDefaultConfig(), config);
if (media)
this.bindMedia(media);
this._logger = new Logger("MSE");
if (this._config.openLog) {
Logger.enable();
}
}

@@ -86,2 +110,7 @@ _createClass(MSE2, [{

}, {
key: "url",
get: function get() {
return this._url;
}
}, {
key: "duration",

@@ -93,2 +122,7 @@ get: function get() {

}, {
key: "isFull",
value: function isFull(type) {
return type ? this._mseFullFlag[type] : this._mseFullFlag[MSE2.VIDEO];
}
}, {
key: "updateDuration",

@@ -109,4 +143,8 @@ value: function updateDuration(duration) {

var onOpen = function onOpen2() {
var costtime = nowTime() - _this4._st;
_this4._logger.debug("MSE OPEN", costtime);
ms.removeEventListener("sourceopen", onOpen2);
_this4._openPromise.resolve();
_this4._openPromise.resolve({
costtime
});
};

@@ -143,11 +181,17 @@ ms.addEventListener("sourceopen", onOpen);

ms = this.mediaSource = new MediaSource();
media.src = URL.createObjectURL(ms);
this._st = nowTime();
onOpen = function onOpen2() {
var costtime = nowTime() - _this5._st;
_this5._logger.debug("MSE OPEN");
ms.removeEventListener("sourceopen", onOpen2);
URL.revokeObjectURL(media.src);
_this5._openPromise.resolve();
_this5._openPromise.resolve({
costtime
});
};
ms.addEventListener("sourceopen", onOpen);
this._url = URL.createObjectURL(ms);
media.src = this._url;
return _context.abrupt("return", this._openPromise);
case 11:
case 13:
case "end":

@@ -258,3 +302,3 @@ return _context.stop();

key: "append",
value: function append(type, buffer) {
value: function append(type, buffer, context) {
var _this7 = this;

@@ -270,11 +314,15 @@ if (!buffer || !buffer.byteLength) {

return;
_this7._logger.debug("MSE APPEND START", context);
_this7._opst = nowTime();
(_this7$_sourceBuffer$ = _this7._sourceBuffer[type]) === null || _this7$_sourceBuffer$ === void 0 ? void 0 : _this7$_sourceBuffer$.appendBuffer(buffer);
});
}, OP_NAME.APPEND, context);
}
}, {
key: "remove",
value: function remove(type, startTime, endTime) {
value: function remove(type, startTime, endTime, context) {
var _this8 = this;
if (Object.keys(this._sourceBuffer).length === 1)
return Promise.resolve();
var isInsertHead = false;
if (this._mseFullFlag[type]) {
isInsertHead = true;
}
return this._enqueueOp(type, function() {

@@ -288,4 +336,6 @@ if (!_this8.mediaSource)

}
_this8._opst = nowTime();
_this8._logger.debug("MSE REMOVE START", type, startTime, endTime, context);
sb.remove(startTime, endTime);
});
}, OP_NAME.REMOVE, context, isInsertHead);
}

@@ -302,2 +352,3 @@ }, {

var sb = _this9._sourceBuffer[k];
_this9._logger.debug("MSE clearBuffer START", k, startTime, endTime);
sb.remove(startTime, endTime);

@@ -318,2 +369,3 @@ });

var sb = _this10._sourceBuffer[k];
_this10._logger.debug("MSE clearAllBuffer START", k);
sb.remove(0, Buffer.end(Buffer.get(sb)));

@@ -325,2 +377,19 @@ });

}, {
key: "clearOpQueues",
value: function clearOpQueues(type) {
var _this$_queue$type;
this._logger.debug("MSE clearOpQueue START");
var queue = this._queue[type];
if (!queue || !queue[type] || queue.length < 5)
return;
var initOpque = [];
queue.forEach(function(op) {
if (op.context && op.context.isinit) {
initOpque.push(op);
}
});
this._queue[type] = queue.slice(0, 2);
initOpque.length > 0 && (_this$_queue$type = this._queue[type]).push.apply(_this$_queue$type, initOpque);
}
}, {
key: "endOfStream",

@@ -335,2 +404,3 @@ value: function endOfStream(reason) {

return;
_this11._logger.debug("MSE endOfStream START");
if (reason) {

@@ -368,3 +438,4 @@ ms.endOfStream(reason);

key: "_enqueueOp",
value: function _enqueueOp(type, exec) {
value: function _enqueueOp(type, exec, opName, context, isInsertHead) {
var _this12 = this;
if (!this.mediaSource)

@@ -375,8 +446,24 @@ return Promise.resolve();

exec,
promise: createPublicPromise()
promise: createPublicPromise(),
opName,
context
};
queue.push(op);
if (queue.length === 1) {
if (isInsertHead) {
queue.splice(0, 0, op);
this._mseFullFlag[type] = false;
this._startQueue(type);
} else {
queue.push(op);
}
if (this.isOpened) {
if (queue.length === 1) {
this._startQueue(type);
}
} else {
this._openPromise.then(function() {
if (queue.length === 1) {
_this12._startQueue(type);
}
});
}
return op.promise;

@@ -388,3 +475,3 @@ }

var _enqueueBlockingOp2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(exec) {
var _this12 = this;
var _this13 = this;
var types, waiters;

@@ -410,3 +497,3 @@ return _regeneratorRuntime().wrap(function _callee3$(_context3) {

types.forEach(function(t) {
var queue = _this12._queue[t];
var queue = _this13._queue[t];
var prom = createPublicPromise();

@@ -421,3 +508,3 @@ waiters.push(prom);

if (queue.length === 1) {
_this12._startQueue(t);
_this13._startQueue(t);
}

@@ -430,7 +517,7 @@ });

types.forEach(function(t) {
var queue = _this12._queue[t];
var sb = _this12._sourceBuffer[t];
var queue = _this13._queue[t];
var sb = _this13._sourceBuffer[t];
queue === null || queue === void 0 ? void 0 : queue.shift();
if (!sb || !sb.updating) {
_this12._startQueue(t);
_this13._startQueue(t);
}

@@ -458,9 +545,16 @@ });

var op = queue[0];
if (op) {
if (op && !this._mseFullFlag[type]) {
try {
op.exec();
} catch (error) {
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
queue.shift();
this._startQueue(type);
if (error && error.message.indexOf("SourceBuffer is full") >= 0) {
this._mseFullFlag[type] = true;
this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_FULL, error));
} else {
this._logger.error(error);
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
queue.shift();
this._startQueue(type);
}
}

@@ -471,2 +565,9 @@ }

}], [{
key: "getDefaultConfig",
value: function getDefaultConfig() {
return {
openLog: false
};
}
}, {
key: "isSupported",

@@ -480,2 +581,3 @@ value: function isSupported() {

} catch (error) {
this._logger.error(mime, error);
return false;

@@ -482,0 +584,0 @@ }

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";

@@ -4,0 +3,0 @@ var NetError = /* @__PURE__ */ function(_Error) {

@@ -1,2 +0,2 @@

import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js";
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js";
import "core-js/modules/es.object.to-string.js";

@@ -6,3 +6,3 @@ import "core-js/modules/es.promise.js";

import "core-js/modules/es.typed-array.uint8-array.js";
import "core-js/modules/es.typed-array.at.js";
import "core-js/modules/esnext.typed-array.at.js";
import "core-js/modules/es.typed-array.copy-within.js";

@@ -14,4 +14,4 @@ import "core-js/modules/es.typed-array.every.js";

import "core-js/modules/es.typed-array.find-index.js";
import "core-js/modules/es.typed-array.find-last.js";
import "core-js/modules/es.typed-array.find-last-index.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.typed-array.for-each.js";

@@ -34,5 +34,2 @@ import "core-js/modules/es.typed-array.includes.js";

import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/esnext.typed-array.to-reversed.js";
import "core-js/modules/esnext.typed-array.to-sorted.js";
import "core-js/modules/esnext.typed-array.with.js";
import "core-js/modules/es.array.slice.js";

@@ -43,20 +40,24 @@ import { NetError } from "./error.js";

import { EVENT } from "../event.js";
import EventEmitter from "event-emitter";
import EventEmitter from "eventemitter3";
var CACHESIZE = 2 * 1024 * 1024;
var FetchLoader = /* @__PURE__ */ function() {
var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
_inherits(FetchLoader2, _EventEmitter);
var _super = _createSuper(FetchLoader2);
function FetchLoader2() {
var _this;
_classCallCheck(this, FetchLoader2);
_defineProperty(this, "_abortController", null);
_defineProperty(this, "_timeoutTimer", null);
_defineProperty(this, "_reader", null);
_defineProperty(this, "_response", null);
_defineProperty(this, "_aborted", false);
_defineProperty(this, "_index", -1);
_defineProperty(this, "_range", null);
_defineProperty(this, "_receivedLength", 0);
_defineProperty(this, "_running", false);
_defineProperty(this, "_logger", null);
_defineProperty(this, "_vid", "");
_defineProperty(this, "_onProcessMinLen", 0);
EventEmitter(this);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "_abortController", null);
_defineProperty(_assertThisInitialized(_this), "_timeoutTimer", null);
_defineProperty(_assertThisInitialized(_this), "_reader", null);
_defineProperty(_assertThisInitialized(_this), "_response", null);
_defineProperty(_assertThisInitialized(_this), "_aborted", false);
_defineProperty(_assertThisInitialized(_this), "_index", -1);
_defineProperty(_assertThisInitialized(_this), "_range", null);
_defineProperty(_assertThisInitialized(_this), "_receivedLength", 0);
_defineProperty(_assertThisInitialized(_this), "_running", false);
_defineProperty(_assertThisInitialized(_this), "_logger", null);
_defineProperty(_assertThisInitialized(_this), "_vid", "");
_defineProperty(_assertThisInitialized(_this), "_onProcessMinLen", 0);
return _this;
}

@@ -66,3 +67,3 @@ _createClass(FetchLoader2, [{

value: function load(_ref) {
var _this$_abortControlle, _this = this;
var _this$_abortControlle, _this2 = this;
var url = _ref.url, vid = _ref.vid, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, index = _ref.index, onTimeout = _ref.onTimeout, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, logger = _ref.logger, 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, onProcessMinLen = _ref.onProcessMinLen;

@@ -108,3 +109,3 @@ this._logger = logger;

isTimeout = true;
_this.cancel();
_this2.cancel();
if (onTimeout) {

@@ -127,5 +128,5 @@ var error = new NetError(url, init);

case 0:
clearTimeout(_this._timeoutTimer);
_this._response = response;
if (!(_this._aborted || !_this._running)) {
clearTimeout(_this2._timeoutTimer);
_this2._response = response;
if (!(_this2._aborted || !_this2._running)) {
_context.next = 4;

@@ -154,3 +155,3 @@ break;

data = _context.sent;
_this._running = false;
_this2._running = false;
_context.next = 37;

@@ -167,3 +168,3 @@ break;

data = _context.sent;
_this._running = false;
_this2._running = false;
_context.next = 37;

@@ -176,5 +177,5 @@ break;

}
_this.resolve = resolve;
_this.reject = reject;
_this._loadChunk(response, onProgress, startTime, firstByteTime);
_this2.resolve = resolve;
_this2.reject = reject;
_this2._loadChunk(response, onProgress, startTime, firstByteTime);
return _context.abrupt("return");

@@ -187,11 +188,11 @@ case 29:

data = new Uint8Array(data);
_this._running = false;
_this2._running = false;
costTime = Date.now() - startTime;
speed = calculateSpeed(data.byteLength, costTime);
_this.emit(EVENT.REAL_TIME_SPEED, {
_this2.emit(EVENT.REAL_TIME_SPEED, {
speed
});
case 37:
_this._logger.debug("[fetch load end], index,", index, ",range,", range);
resolve(createResponse(data, true, response, response.headers.get("Content-Length"), response.headers.get("age"), startTime, firstByteTime, index, range, _this._vid));
_this2._logger.debug("[fetch load end], index,", index, ",range,", range);
resolve(createResponse(data, true, response, response.headers.get("Content-Length"), response.headers.get("age"), startTime, firstByteTime, index, range, _this2._vid));
case 39:

@@ -208,5 +209,5 @@ case "end":

}()).catch(function(error) {
clearTimeout(_this._timeoutTimer);
_this._running = false;
if (_this._aborted && !isTimeout)
clearTimeout(_this2._timeoutTimer);
_this2._running = false;
if (_this2._aborted && !isTimeout)
return;

@@ -279,3 +280,3 @@ error = error instanceof NetError ? error : new NetError(url, init);

value: function _loadChunk(response, onProgress, st, firstByteTime) {
var _this2 = this;
var _this3 = this;
if (!response.body || !response.body.getReader) {

@@ -314,18 +315,18 @@ this._running = false;

endTime = Date.now();
if (!_this2._aborted) {
_this2._running = false;
_this2.reject(_context3.t0);
if (!_this3._aborted) {
_this3._running = false;
_this3.reject(_context3.t0);
}
return _context3.abrupt("return");
case 13:
startByte = _this2._range[0] + _this2._receivedLength;
if (!_this2._aborted) {
startByte = _this3._range[0] + _this3._receivedLength;
if (!_this3._aborted) {
_context3.next = 18;
break;
}
_this2._running = false;
_this3._running = false;
onProgress(void 0, false, {
range: [startByte, startByte],
vid: _this2._vid,
index: _this2._index,
vid: _this3._vid,
index: _this3._index,
startTime,

@@ -337,25 +338,25 @@ endTime

curLen = data.value ? data.value.byteLength : 0;
_this2._receivedLength += curLen;
_this2._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,", _this2._range, ", start,", startByte, ", end,", _this2._range[0] + _this2._receivedLength, ", done,", data.done);
if (_this2._onProcessMinLen > 0) {
if (_this2._writeIdx + curLen >= _this2._onProcessMinLen || data.done) {
retData = new Uint8Array(_this2._writeIdx + curLen);
retData.set(_this2._cache.slice(0, _this2._writeIdx), 0);
curLen > 0 && retData.set(data.value, _this2._writeIdx);
_this2._writeIdx = 0;
_this2._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,", data.done, ",len,", retData.byteLength, ", writeIdx,", _this2._writeIdx);
_this3._receivedLength += curLen;
_this3._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,", _this3._range, ", start,", startByte, ", end,", _this3._range[0] + _this3._receivedLength, ", done,", data.done);
if (_this3._onProcessMinLen > 0) {
if (_this3._writeIdx + curLen >= _this3._onProcessMinLen || data.done) {
retData = new Uint8Array(_this3._writeIdx + curLen);
retData.set(_this3._cache.slice(0, _this3._writeIdx), 0);
curLen > 0 && retData.set(data.value, _this3._writeIdx);
_this3._writeIdx = 0;
_this3._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,", data.done, ",len,", retData.byteLength, ", writeIdx,", _this3._writeIdx);
} else {
if (curLen > 0 && _this2._writeIdx + curLen < CACHESIZE) {
_this2._cache.set(data.value, _this2._writeIdx);
_this2._writeIdx += curLen;
_this2._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,", curLen, ", writeIdx,", _this2._writeIdx);
if (curLen > 0 && _this3._writeIdx + curLen < CACHESIZE) {
_this3._cache.set(data.value, _this3._writeIdx);
_this3._writeIdx += curLen;
_this3._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,", curLen, ", writeIdx,", _this3._writeIdx);
} else if (curLen > 0) {
temp = new Uint8Array(_this2._writeIdx + curLen + 2048);
_this2._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,", _this2._writeIdx + curLen + 2048, ", datalen,", curLen, ", writeIdx,", _this2._writeIdx);
temp.set(_this2._cache.slice(0, _this2._writeIdx), 0);
curLen > 0 && temp.set(data.value, _this2._writeIdx);
_this2._writeIdx += curLen;
delete _this2._cache;
_this2._cache = temp;
_this2._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,", curLen, ", writeIdx,", _this2._writeIdx);
temp = new Uint8Array(_this3._writeIdx + curLen + 2048);
_this3._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,", _this3._writeIdx + curLen + 2048, ", datalen,", curLen, ", writeIdx,", _this3._writeIdx);
temp.set(_this3._cache.slice(0, _this3._writeIdx), 0);
curLen > 0 && temp.set(data.value, _this3._writeIdx);
_this3._writeIdx += curLen;
delete _this3._cache;
_this3._cache = temp;
_this3._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,", curLen, ", writeIdx,", _this3._writeIdx);
}

@@ -368,5 +369,5 @@ }

onProgress(retData, data.done, {
range: [_this2._range[0] + _this2._receivedLength - (retData ? retData.byteLength : 0), _this2._range[0] + _this2._receivedLength],
vid: _this2._vid,
index: _this2._index,
range: [_this3._range[0] + _this3._receivedLength - (retData ? retData.byteLength : 0), _this3._range[0] + _this3._receivedLength],
vid: _this3._vid,
index: _this3._index,
startTime,

@@ -377,4 +378,4 @@ endTime

costTime = Date.now() - st;
speed = calculateSpeed(_this2._receivedLength, costTime);
_this2.emit(EVENT.REAL_TIME_SPEED, {
speed = calculateSpeed(_this3._receivedLength, costTime);
_this3.emit(EVENT.REAL_TIME_SPEED, {
speed

@@ -385,5 +386,5 @@ });

} else {
_this2._running = false;
_this2._logger.debug("[fetchLoader onProgress end],task,", _this2._range, ",done,", data.done);
_this2.resolve(createResponse(data, true, response, response.headers.get("Content-Length"), response.headers.get("age"), startTime, firstByteTime, _this2._index, _this2._range, _this2._vid));
_this3._running = false;
_this3._logger.debug("[fetchLoader onProgress end],task,", _this3._range, ",done,", data.done);
_this3.resolve(createResponse(data, true, response, response.headers.get("Content-Length"), response.headers.get("age"), startTime, firstByteTime, _this3._index, _this3._range, _this3._vid));
}

@@ -423,3 +424,3 @@ case 27:

return FetchLoader2;
}();
}(EventEmitter);
export { FetchLoader };

@@ -82,4 +82,4 @@ import "core-js/modules/es.regexp.exec.js";

function calculateSpeed(byteLen, millisec) {
return Math.round(byteLen * 8 * 1e3 / millisec);
return Math.round(byteLen * 8 * 1e3 / millisec / 1024);
}
export { calculateSpeed, createResponse, getRangeValue, setUrlParams };

@@ -1,4 +0,3 @@

import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js";
import { inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js";
import "core-js/modules/es.object.assign.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.array.concat.js";

@@ -21,16 +20,21 @@ import "core-js/modules/es.array.map.js";

import { EVENT } from "../event.js";
import EventEmitter from "event-emitter";
var NetLoader = /* @__PURE__ */ function() {
import EventEmitter from "eventemitter3";
var NetLoader = /* @__PURE__ */ function(_EventEmitter) {
_inherits(NetLoader2, _EventEmitter);
var _super = _createSuper(NetLoader2);
function NetLoader2(cfg) {
var _this;
_classCallCheck(this, NetLoader2);
_defineProperty(this, "type", LoaderType.FETCH);
_defineProperty(this, "_queue", []);
_defineProperty(this, "_alive", []);
_defineProperty(this, "_currentTask", null);
EventEmitter(this);
this._config = getConfig(cfg);
if (this._config.loaderType === LoaderType.XHR || !FetchLoader.isSupported()) {
this.type = LoaderType.XHR;
_this = _super.call(this, cfg);
_defineProperty(_assertThisInitialized(_this), "type", LoaderType.FETCH);
_defineProperty(_assertThisInitialized(_this), "_queue", []);
_defineProperty(_assertThisInitialized(_this), "_alive", []);
_defineProperty(_assertThisInitialized(_this), "_currentTask", null);
_defineProperty(_assertThisInitialized(_this), "_config", void 0);
_this._config = getConfig(cfg);
if (_this._config.loaderType === LoaderType.XHR || !FetchLoader.isSupported()) {
_this.type = LoaderType.XHR;
}
this.log = cfg.logger;
_this.log = cfg.logger;
return _this;
}

@@ -45,3 +49,3 @@ _createClass(NetLoader2, [{

value: function load(url) {
var _this = this;
var _this2 = this;
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};

@@ -66,3 +70,3 @@ if (typeof url === "string" || !url) {

task.loader.on(EVENT.REAL_TIME_SPEED, function(data) {
_this.emit(EVENT.REAL_TIME_SPEED, data);
_this2.emit(EVENT.REAL_TIME_SPEED, data);
});

@@ -114,3 +118,3 @@ this._queue.push(task);

value: function _processTask() {
var _this2 = this;
var _this3 = this;
this._currentTask = this._queue.shift();

@@ -124,3 +128,3 @@ if (!this._currentTask)

}).finally(function() {
_this2._processTask();
_this3._processTask();
});

@@ -135,3 +139,3 @@ }

return NetLoader2;
}();
}(EventEmitter);
export { NetLoader };

@@ -13,4 +13,2 @@ export class XhrLoader {

_currentChunkSizeKB: number;
_currentSpeedNormalized: number;
_zeroSpeedChunkCount: number;
_timeout: any;

@@ -17,0 +15,0 @@ _withCredentials: any;

@@ -1,2 +0,2 @@

import { createClass as _createClass, objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js";
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectSpread2 as _objectSpread2, get as _get, getPrototypeOf as _getPrototypeOf, createForOfIteratorHelper as _createForOfIteratorHelper } from "../_virtual/_rollupPluginBabelHelpers.js";
import "core-js/modules/es.object.to-string.js";

@@ -8,3 +8,3 @@ import "core-js/modules/es.promise.js";

import "core-js/modules/es.typed-array.uint8-array.js";
import "core-js/modules/es.typed-array.at.js";
import "core-js/modules/esnext.typed-array.at.js";
import "core-js/modules/es.typed-array.copy-within.js";

@@ -16,4 +16,4 @@ import "core-js/modules/es.typed-array.every.js";

import "core-js/modules/es.typed-array.find-index.js";
import "core-js/modules/es.typed-array.find-last.js";
import "core-js/modules/es.typed-array.find-last-index.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.typed-array.for-each.js";

@@ -36,5 +36,2 @@ import "core-js/modules/es.typed-array.includes.js";

import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/esnext.typed-array.to-reversed.js";
import "core-js/modules/esnext.typed-array.to-sorted.js";
import "core-js/modules/esnext.typed-array.with.js";
import "core-js/modules/es.string.trim.js";

@@ -47,34 +44,36 @@ import "core-js/modules/es.array.join.js";

import { EVENT } from "../event.js";
import EventEmitter from "event-emitter";
var XhrLoader = /* @__PURE__ */ function() {
import EventEmitter from "eventemitter3";
var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
_inherits(XhrLoader2, _EventEmitter);
var _super = _createSuper(XhrLoader2);
function XhrLoader2() {
var _this;
_classCallCheck(this, XhrLoader2);
_defineProperty(this, "_xhr", null);
_defineProperty(this, "_aborted", false);
_defineProperty(this, "_timeoutTimer", null);
_defineProperty(this, "_range", null);
_defineProperty(this, "_receivedLength", 0);
_defineProperty(this, "_url", null);
_defineProperty(this, "_onProgress", null);
_defineProperty(this, "_index", -1);
_defineProperty(this, "_headers", null);
_defineProperty(this, "_currentChunkSizeKB", 384);
_defineProperty(this, "_currentSpeedNormalized", 0);
_defineProperty(this, "_zeroSpeedChunkCount", 0);
_defineProperty(this, "_timeout", null);
_defineProperty(this, "_xhr", null);
_defineProperty(this, "_withCredentials", null);
_defineProperty(this, "_startTime", -1);
_defineProperty(this, "_loadCompleteResolve", null);
_defineProperty(this, "_loadCompleteReject", null);
_defineProperty(this, "_runing", false);
_defineProperty(this, "_logger", false);
_defineProperty(this, "_vid", "");
_defineProperty(this, "_responseType", void 0);
_defineProperty(this, "_credentials", void 0);
_defineProperty(this, "_method", void 0);
_defineProperty(this, "_transformResponse", void 0);
_defineProperty(this, "_firstRtt", void 0);
_defineProperty(this, "_subRangeStartTime", void 0);
EventEmitter(this);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "_xhr", null);
_defineProperty(_assertThisInitialized(_this), "_aborted", false);
_defineProperty(_assertThisInitialized(_this), "_timeoutTimer", null);
_defineProperty(_assertThisInitialized(_this), "_range", null);
_defineProperty(_assertThisInitialized(_this), "_receivedLength", 0);
_defineProperty(_assertThisInitialized(_this), "_url", null);
_defineProperty(_assertThisInitialized(_this), "_onProgress", null);
_defineProperty(_assertThisInitialized(_this), "_index", -1);
_defineProperty(_assertThisInitialized(_this), "_headers", null);
_defineProperty(_assertThisInitialized(_this), "_currentChunkSizeKB", 384);
_defineProperty(_assertThisInitialized(_this), "_timeout", null);
_defineProperty(_assertThisInitialized(_this), "_xhr", null);
_defineProperty(_assertThisInitialized(_this), "_withCredentials", null);
_defineProperty(_assertThisInitialized(_this), "_startTime", -1);
_defineProperty(_assertThisInitialized(_this), "_loadCompleteResolve", null);
_defineProperty(_assertThisInitialized(_this), "_loadCompleteReject", null);
_defineProperty(_assertThisInitialized(_this), "_runing", false);
_defineProperty(_assertThisInitialized(_this), "_logger", false);
_defineProperty(_assertThisInitialized(_this), "_vid", "");
_defineProperty(_assertThisInitialized(_this), "_responseType", void 0);
_defineProperty(_assertThisInitialized(_this), "_credentials", void 0);
_defineProperty(_assertThisInitialized(_this), "_method", void 0);
_defineProperty(_assertThisInitialized(_this), "_transformResponse", void 0);
_defineProperty(_assertThisInitialized(_this), "_firstRtt", void 0);
_defineProperty(_assertThisInitialized(_this), "_subRangeStartTime", void 0);
return _this;
}

@@ -84,3 +83,3 @@ _createClass(XhrLoader2, [{

value: function load(req) {
var _this = this;
var _this2 = this;
clearTimeout(this._timeoutTimer);

@@ -105,11 +104,11 @@ this._logger = req.logger;

return new Promise(function(resolve, reject) {
_this._loadCompleteResolve = resolve;
_this._loadCompleteReject = reject;
_this._startLoad();
_this2._loadCompleteResolve = resolve;
_this2._loadCompleteReject = reject;
_this2._startLoad();
}).catch(function(error) {
clearTimeout(_this._timeoutTimer);
_this._runing = false;
if (_this._aborted)
clearTimeout(_this2._timeoutTimer);
_this2._runing = false;
if (_this2._aborted)
return;
error = error instanceof NetError ? error : new NetError(_this._url, _this._request);
error = error instanceof NetError ? error : new NetError(_this2._url, _this2._request);
error.startTime = startTime;

@@ -146,3 +145,3 @@ error.endTime = Date.now();

value: function _internalOpen(range) {
var _this2 = this;
var _this3 = this;
try {

@@ -158,13 +157,13 @@ this._startTime = Date.now();

xhr.onerror = function(event) {
_this2._running = false;
_this2._loadCompleteReject(event);
_this3._running = false;
_this3._loadCompleteReject(event);
};
xhr.ontimeout = function(event) {
_this2.cancel();
if (_this2._onTimeout) {
var error = new NetError(_this2._url, _this2._request);
_this3.cancel();
if (_this3._onTimeout) {
var error = new NetError(_this3._url, _this3._request);
error.isTimeout = true;
_this2._onTimeout(error);
_this3._onTimeout(error);
}
_this2._loadCompleteReject(event);
_this3._loadCompleteReject(event);
};

@@ -264,2 +263,3 @@ var rangeValue = getRangeValue(range);

this._runing = false;
_get(_getPrototypeOf(XhrLoader2.prototype), "removeAllListeners", this).call(this);
if (this._xhr) {

@@ -308,3 +308,3 @@ return this._xhr.abort();

return XhrLoader2;
}();
}(EventEmitter);
export { XhrLoader };
import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.array.slice.js";

@@ -4,0 +3,0 @@ import "core-js/modules/es.object.to-string.js";

@@ -8,3 +8,2 @@ import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js";

import "core-js/modules/web.dom-collections.for-each.js";
import "core-js/modules/es.array.push.js";
import { EVENT } from "../event.js";

@@ -11,0 +10,0 @@ var SeiService = /* @__PURE__ */ function() {

@@ -5,3 +5,3 @@ import "core-js/modules/es.array.filter.js";

import "core-js/modules/es.typed-array.uint8-array.js";
import "core-js/modules/es.typed-array.at.js";
import "core-js/modules/esnext.typed-array.at.js";
import "core-js/modules/es.typed-array.copy-within.js";

@@ -13,4 +13,4 @@ import "core-js/modules/es.typed-array.every.js";

import "core-js/modules/es.typed-array.find-index.js";
import "core-js/modules/es.typed-array.find-last.js";
import "core-js/modules/es.typed-array.find-last-index.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.typed-array.for-each.js";

@@ -33,5 +33,2 @@ import "core-js/modules/es.typed-array.includes.js";

import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/esnext.typed-array.to-reversed.js";
import "core-js/modules/esnext.typed-array.to-sorted.js";
import "core-js/modules/esnext.typed-array.with.js";
import "core-js/modules/web.dom-collections.for-each.js";

@@ -38,0 +35,0 @@ import "core-js/modules/es.promise.js";

export function createPublicPromise(): any;
export function nowTime(): any;

@@ -20,2 +20,9 @@ import "core-js/modules/es.object.to-string.js";

}
export { createPublicPromise };
function nowTime() {
try {
return parseInt(performance.now(), 10);
} catch (e) {
return new Date().getTime();
}
}
export { createPublicPromise, nowTime };
{
"name": "xgplayer-streaming-shared",
"version": "3.0.0-alpha.5-21",
"version": "3.0.0-alpha.5-22",
"main": "dist/index.min.js",

@@ -22,3 +22,3 @@ "module": "es/index.js",

"dependencies": {
"event-emitter": "^0.3.5"
"eventemitter3": "^4.0.7"
},

@@ -25,0 +25,0 @@ "unpkgFiles": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc