cos-js-sdk-v5
Version:
JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)
1,400 lines (1,389 loc) • 521 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["COS"] = factory();
else
root["COS"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./index.js":
/*!******************!*\
!*** ./index.js ***!
\******************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var COS = __webpack_require__(/*! ./src/cos */ "./src/cos.js");
module.exports = COS;
/***/ }),
/***/ "./lib/base64.js":
/*!***********************!*\
!*** ./lib/base64.js ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports) {
/*
* $Id: base64.js,v 2.15 2014/04/05 12:58:57 dankogai Exp dankogai $
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*/
var Base64 = function (global) {
global = global || {};
'use strict';
// existing version for noConflict()
var _Base64 = global.Base64;
var version = "2.1.9";
// if node.js, we use Buffer
var buffer;
// constants
var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64tab = function (bin) {
var t = {};
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
return t;
}(b64chars);
var fromCharCode = String.fromCharCode;
// encoder stuff
var cb_utob = function cb_utob(c) {
if (c.length < 2) {
var cc = c.charCodeAt(0);
return cc < 0x80 ? c : cc < 0x800 ? fromCharCode(0xc0 | cc >>> 6) + fromCharCode(0x80 | cc & 0x3f) : fromCharCode(0xe0 | cc >>> 12 & 0x0f) + fromCharCode(0x80 | cc >>> 6 & 0x3f) + fromCharCode(0x80 | cc & 0x3f);
} else {
var cc = 0x10000 + (c.charCodeAt(0) - 0xD800) * 0x400 + (c.charCodeAt(1) - 0xDC00);
return fromCharCode(0xf0 | cc >>> 18 & 0x07) + fromCharCode(0x80 | cc >>> 12 & 0x3f) + fromCharCode(0x80 | cc >>> 6 & 0x3f) + fromCharCode(0x80 | cc & 0x3f);
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = function utob(u) {
return u.replace(re_utob, cb_utob);
};
var cb_encode = function cb_encode(ccc) {
var padlen = [0, 2, 1][ccc.length % 3],
ord = ccc.charCodeAt(0) << 16 | (ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8 | (ccc.length > 2 ? ccc.charCodeAt(2) : 0),
chars = [b64chars.charAt(ord >>> 18), b64chars.charAt(ord >>> 12 & 63), padlen >= 2 ? '=' : b64chars.charAt(ord >>> 6 & 63), padlen >= 1 ? '=' : b64chars.charAt(ord & 63)];
return chars.join('');
};
var btoa = global.btoa ? function (b) {
return global.btoa(b);
} : function (b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode);
};
var _encode = buffer ? function (u) {
return (u.constructor === buffer.constructor ? u : new buffer(u)).toString('base64');
} : function (u) {
return btoa(utob(u));
};
var encode = function encode(u, urisafe) {
return !urisafe ? _encode(String(u)) : _encode(String(u)).replace(/[+\/]/g, function (m0) {
return m0 == '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function encodeURI(u) {
return encode(u, true);
};
// decoder stuff
var re_btou = new RegExp(['[\xC0-\xDF][\x80-\xBF]', '[\xE0-\xEF][\x80-\xBF]{2}', '[\xF0-\xF7][\x80-\xBF]{3}'].join('|'), 'g');
var cb_btou = function cb_btou(cccc) {
switch (cccc.length) {
case 4:
var cp = (0x07 & cccc.charCodeAt(0)) << 18 | (0x3f & cccc.charCodeAt(1)) << 12 | (0x3f & cccc.charCodeAt(2)) << 6 | 0x3f & cccc.charCodeAt(3),
offset = cp - 0x10000;
return fromCharCode((offset >>> 10) + 0xD800) + fromCharCode((offset & 0x3FF) + 0xDC00);
case 3:
return fromCharCode((0x0f & cccc.charCodeAt(0)) << 12 | (0x3f & cccc.charCodeAt(1)) << 6 | 0x3f & cccc.charCodeAt(2));
default:
return fromCharCode((0x1f & cccc.charCodeAt(0)) << 6 | 0x3f & cccc.charCodeAt(1));
}
};
var btou = function btou(b) {
return b.replace(re_btou, cb_btou);
};
var cb_decode = function cb_decode(cccc) {
var len = cccc.length,
padlen = len % 4,
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0) | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0) | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0) | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
chars = [fromCharCode(n >>> 16), fromCharCode(n >>> 8 & 0xff), fromCharCode(n & 0xff)];
chars.length -= [0, 0, 2, 1][padlen];
return chars.join('');
};
var atob = global.atob ? function (a) {
return global.atob(a);
} : function (a) {
return a.replace(/[\s\S]{1,4}/g, cb_decode);
};
var _decode = buffer ? function (a) {
return (a.constructor === buffer.constructor ? a : new buffer(a, 'base64')).toString();
} : function (a) {
return btou(atob(a));
};
var decode = function decode(a) {
return _decode(String(a).replace(/[-_]/g, function (m0) {
return m0 == '-' ? '+' : '/';
}).replace(/[^A-Za-z0-9\+\/]/g, ''));
};
var noConflict = function noConflict() {
var Base64 = global.Base64;
global.Base64 = _Base64;
return Base64;
};
// export Base64
var Base64 = {
VERSION: version,
atob: atob,
btoa: btoa,
fromBase64: decode,
toBase64: encode,
utob: utob,
encode: encode,
encodeURI: encodeURI,
btou: btou,
decode: decode,
noConflict: noConflict
};
return Base64;
}();
module.exports = Base64;
/***/ }),
/***/ "./lib/beacon.min.js":
/*!***************************!*\
!*** ./lib/beacon.min.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
!function (t, e) {
"object" == ( false ? undefined : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (e),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
}(this, function () {
"use strict";
var _t = function t(e, n) {
return _t = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (t, e) {
t.__proto__ = e;
} || function (t, e) {
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
}, _t(e, n);
};
var _e = function e() {
return _e = Object.assign || function (t) {
for (var e, n = 1, r = arguments.length; n < r; n++) for (var o in e = arguments[n]) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
return t;
}, _e.apply(this, arguments);
};
function n(t, e, n, r) {
return new (n || (n = Promise))(function (o, i) {
function s(t) {
try {
u(r.next(t));
} catch (t) {
i(t);
}
}
function a(t) {
try {
u(r.throw(t));
} catch (t) {
i(t);
}
}
function u(t) {
var e;
t.done ? o(t.value) : (e = t.value, e instanceof n ? e : new n(function (t) {
t(e);
})).then(s, a);
}
u((r = r.apply(t, e || [])).next());
});
}
function r(t, e) {
var n,
r,
o,
i,
s = {
label: 0,
sent: function sent() {
if (1 & o[0]) throw o[1];
return o[1];
},
trys: [],
ops: []
};
return i = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (i[Symbol.iterator] = function () {
return this;
}), i;
function a(i) {
return function (a) {
return function (i) {
if (n) throw new TypeError("Generator is already executing.");
for (; s;) try {
if (n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o;
switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) {
case 0:
case 1:
o = i;
break;
case 4:
return s.label++, {
value: i[1],
done: !1
};
case 5:
s.label++, r = i[1], i = [0];
continue;
case 7:
i = s.ops.pop(), s.trys.pop();
continue;
default:
if (!(o = s.trys, (o = o.length > 0 && o[o.length - 1]) || 6 !== i[0] && 2 !== i[0])) {
s = 0;
continue;
}
if (3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) {
s.label = i[1];
break;
}
if (6 === i[0] && s.label < o[1]) {
s.label = o[1], o = i;
break;
}
if (o && s.label < o[2]) {
s.label = o[2], s.ops.push(i);
break;
}
o[2] && s.ops.pop(), s.trys.pop();
continue;
}
i = e.call(t, s);
} catch (t) {
i = [6, t], r = 0;
} finally {
n = o = 0;
}
if (5 & i[0]) throw i[1];
return {
value: i[0] ? i[1] : void 0,
done: !0
};
}([i, a]);
};
}
}
var o = "__BEACON_",
i = "__BEACON_deviceId",
s = "last_report_time",
a = "sending_event_ids",
u = "beacon_config",
c = "beacon_config_request_time",
l = function () {
function t() {
var t = this;
this.emit = function (e, n) {
if (t) {
var r,
o = t.__EventsList[e];
if (null == o ? void 0 : o.length) {
o = o.slice();
for (var i = 0; i < o.length; i++) {
r = o[i];
try {
var s = r.callback.apply(t, [n]);
if (1 === r.type && t.remove(e, r.callback), !1 === s) break;
} catch (t) {
throw t;
}
}
}
return t;
}
}, this.__EventsList = {};
}
return t.prototype.indexOf = function (t, e) {
for (var n = 0; n < t.length; n++) if (t[n].callback === e) return n;
return -1;
}, t.prototype.on = function (t, e, n) {
if (void 0 === n && (n = 0), this) {
var r = this.__EventsList[t];
if (r || (r = this.__EventsList[t] = []), -1 === this.indexOf(r, e)) {
var o = {
name: t,
type: n || 0,
callback: e
};
return r.push(o), this;
}
return this;
}
}, t.prototype.one = function (t, e) {
this.on(t, e, 1);
}, t.prototype.remove = function (t, e) {
if (this) {
var n = this.__EventsList[t];
if (!n) return null;
if (!e) {
try {
delete this.__EventsList[t];
} catch (t) {}
return null;
}
if (n.length) {
var r = this.indexOf(n, e);
n.splice(r, 1);
}
return this;
}
}, t;
}();
function p(t, e) {
for (var n = {}, r = 0, o = Object.keys(t); r < o.length; r++) {
var i = o[r],
s = t[i];
if ("string" == typeof s) n[h(i)] = h(s);else {
if (e) throw new Error("value mast be string !!!!");
n[h(String(i))] = h(String(s));
}
}
return n;
}
function h(t) {
if ("string" != typeof t) return t;
try {
return t.replace(new RegExp("\\|", "g"), "%7C").replace(new RegExp("\\&", "g"), "%26").replace(new RegExp("\\=", "g"), "%3D").replace(new RegExp("\\+", "g"), "%2B");
} catch (t) {
return "";
}
}
function f(t) {
return String(t.A99) + String(t.A100);
}
var d = function d() {};
var v = function () {
function t(t) {
var n = this;
this.lifeCycle = new l(), this.uploadJobQueue = [], this.additionalParams = {}, this.delayTime = 0, this._normalLogPipeline = function (t) {
if (!t || !t.reduce || !t.length) throw new TypeError("createPipeline 方法需要传入至少有一个 pipe 的数组");
return 1 === t.length ? function (e, n) {
t[0](e, n || d);
} : t.reduce(function (t, e) {
return function (n, r) {
return void 0 === r && (r = d), t(n, function (t) {
return null == e ? void 0 : e(t, r);
});
};
});
}([function (t) {
n.send({
url: n.strategy.getUploadUrl(),
data: t,
method: "post",
contentType: "application/json;charset=UTF-8"
}, function () {
var e = n.config.onReportSuccess;
"function" == typeof e && e(JSON.stringify(t.events));
}, function () {
var e = n.config.onReportFail;
"function" == typeof e && e(JSON.stringify(t.events));
});
}]), function (t, e) {
if (!t) throw e instanceof Error ? e : new Error(e);
}(Boolean(t.appkey), "appkey must be initial"), this.config = _e({}, t);
}
return t.prototype.onUserAction = function (t, e) {
this.preReport(t, e, !1);
}, t.prototype.onDirectUserAction = function (t, e) {
this.preReport(t, e, !0);
}, t.prototype.preReport = function (t, e, n) {
t ? this.strategy.isEventUpOnOff() && (this.strategy.isBlackEvent(t) || this.strategy.isSampleEvent(t) || this.onReport(t, e, n)) : this.errorReport.reportError("602", " no eventCode");
}, t.prototype.addAdditionalParams = function (t) {
for (var e = 0, n = Object.keys(t); e < n.length; e++) {
var r = n[e];
this.additionalParams[r] = t[r];
}
}, t.prototype.setChannelId = function (t) {
this.commonInfo.channelID = String(t);
}, t.prototype.setOpenId = function (t) {
this.commonInfo.openid = String(t);
}, t.prototype.setUnionid = function (t) {
this.commonInfo.unid = String(t);
}, t.prototype.getDeviceId = function () {
return this.commonInfo.deviceId;
}, t.prototype.getCommonInfo = function () {
return this.commonInfo;
}, t.prototype.removeSendingId = function (t) {
try {
var e = JSON.parse(this.storage.getItem(a)),
n = e.indexOf(t);
-1 != n && (e.splice(n, 1), this.storage.setItem(a, JSON.stringify(e)));
} catch (t) {}
}, t;
}(),
g = function () {
function t(t, e, n, r) {
this.requestParams = {}, this.network = r, this.requestParams.attaid = "00400014144", this.requestParams.token = "6478159937", this.requestParams.product_id = t.appkey, this.requestParams.platform = n, this.requestParams.uin = e.deviceId, this.requestParams.model = "", this.requestParams.os = n, this.requestParams.app_version = t.appVersion, this.requestParams.sdk_version = e.sdkVersion, this.requestParams.error_stack = "", this.uploadUrl = t.isOversea ? "https://htrace.wetvinfo.com/kv" : "https://h.trace.qq.com/kv";
}
return t.prototype.reportError = function (t, e) {
this.requestParams._dc = Math.random(), this.requestParams.error_msg = e, this.requestParams.error_code = t, this.network.get(this.uploadUrl, {
params: this.requestParams
}).catch(function (t) {});
}, t;
}(),
y = function () {
function t(t, e, n, r, o) {
this.strategy = {
isEventUpOnOff: !0,
httpsUploadUrl: "https://otheve.beacon.qq.com/analytics/v2_upload",
requestInterval: 30,
blacklist: [],
samplelist: []
}, this.realSample = {}, this.appkey = "", this.needQueryConfig = !0, this.appkey = e.appkey, this.storage = r, this.needQueryConfig = t;
try {
var i = JSON.parse(this.storage.getItem(u));
i && this.processData(i);
} catch (t) {}
e.isOversea && (this.strategy.httpsUploadUrl = "https://svibeacon.onezapp.com/analytics/v2_upload"), !e.isOversea && this.needRequestConfig() && this.requestConfig(e.appVersion, n, o);
}
return t.prototype.requestConfig = function (t, e, n) {
var r = this;
this.storage.setItem(c, Date.now().toString()), n.post("https://oth.str.beacon.qq.com/trpc.beacon.configserver.BeaconConfigService/QueryConfig", {
platformId: "undefined" == typeof wx ? "3" : "4",
mainAppKey: this.appkey,
appVersion: t,
sdkVersion: e.sdkVersion,
osVersion: e.userAgent,
model: "",
packageName: "",
params: {
A3: e.deviceId
}
}).then(function (t) {
if (0 == t.data.ret) try {
var e = JSON.parse(t.data.beaconConfig);
e && (r.processData(e), r.storage.setItem(u, t.data.beaconConfig));
} catch (t) {} else r.processData(null), r.storage.setItem(u, "");
}).catch(function (t) {});
}, t.prototype.processData = function (t) {
var e, n, r, o, i;
this.strategy.isEventUpOnOff = null !== (e = null == t ? void 0 : t.isEventUpOnOff) && void 0 !== e ? e : this.strategy.isEventUpOnOff, this.strategy.httpsUploadUrl = null !== (n = null == t ? void 0 : t.httpsUploadUrl) && void 0 !== n ? n : this.strategy.httpsUploadUrl, this.strategy.requestInterval = null !== (r = null == t ? void 0 : t.requestInterval) && void 0 !== r ? r : this.strategy.requestInterval, this.strategy.blacklist = null !== (o = null == t ? void 0 : t.blacklist) && void 0 !== o ? o : this.strategy.blacklist, this.strategy.samplelist = null !== (i = null == t ? void 0 : t.samplelist) && void 0 !== i ? i : this.strategy.samplelist;
for (var s = 0, a = this.strategy.samplelist; s < a.length; s++) {
var u = a[s].split(",");
2 == u.length && (this.realSample[u[0]] = u[1]);
}
}, t.prototype.needRequestConfig = function () {
if (!this.needQueryConfig) return !1;
var t = Number(this.storage.getItem(c));
return Date.now() - t > 60 * this.strategy.requestInterval * 1e3;
}, t.prototype.getUploadUrl = function () {
return this.strategy.httpsUploadUrl + "?appkey=" + this.appkey;
}, t.prototype.isBlackEvent = function (t) {
return -1 != this.strategy.blacklist.indexOf(t);
}, t.prototype.isEventUpOnOff = function () {
return this.strategy.isEventUpOnOff;
}, t.prototype.isSampleEvent = function (t) {
return !!Object.prototype.hasOwnProperty.call(this.realSample, t) && this.realSample[t] < Math.floor(Math.random() * Math.floor(1e4));
}, t;
}(),
m = "session_storage_key",
w = function () {
function t(t, e, n) {
this.getSessionStackDepth = 0, this.beacon = n, this.storage = t, this.duration = e, this.appkey = n.config.appkey;
}
return t.prototype.getSession = function () {
this.getSessionStackDepth += 1;
var t = this.storage.getItem(m);
if (!t) return this.createSession();
var e = "",
n = 0;
try {
var r = JSON.parse(t) || {
sessionId: void 0,
sessionStart: void 0
};
if (!r.sessionId || !r.sessionStart) return this.createSession();
var o = Number(this.storage.getItem(s));
if (Date.now() - o > this.duration) return this.createSession();
e = r.sessionId, n = r.sessionStart, this.getSessionStackDepth = 0;
} catch (t) {}
return {
sessionId: e,
sessionStart: n
};
}, t.prototype.createSession = function () {
var t = Date.now(),
e = {
sessionId: this.appkey + "_" + t.toString(),
sessionStart: t
};
this.storage.setItem(m, JSON.stringify(e)), this.storage.setItem(s, t.toString());
var n = "is_new_user",
r = this.storage.getItem(n);
return this.getSessionStackDepth <= 1 && this.beacon.onDirectUserAction("rqd_applaunched", {
A21: r ? "N" : "Y"
}), this.storage.setItem(n, JSON.stringify(!1)), e;
}, t;
}();
function b() {
var t = navigator.userAgent,
e = t.indexOf("compatible") > -1 && t.indexOf("MSIE") > -1,
n = t.indexOf("Edge") > -1 && !e,
r = t.indexOf("Trident") > -1 && t.indexOf("rv:11.0") > -1;
if (e) {
new RegExp("MSIE (\\d+\\.\\d+);").test(t);
var o = parseFloat(RegExp.$1);
return 7 == o ? 7 : 8 == o ? 8 : 9 == o ? 9 : 10 == o ? 10 : 6;
}
return n ? -2 : r ? 11 : -1;
}
function S(t, e) {
var n, r;
return (n = "https://tun-cos-1258344701.file.myqcloud.com/fp.js", void 0 === r && (r = Date.now() + "-" + Math.random()), new Promise(function (t, e) {
if (document.getElementById(r)) t(void 0);else {
var o = document.getElementsByTagName("head")[0],
i = document.createElement("script");
i.onload = function () {
return function () {
i.onload = null, t(void 0);
};
}, i.onerror = function (t) {
i.onerror = null, o.removeChild(i), e(t);
}, i.src = n, i.id = r, o.appendChild(i);
}
})).then(function () {
new Fingerprint().getQimei36(t, e);
}).catch(function (t) {}), "";
}
var _I = function I() {
return (_I = Object.assign || function (t) {
for (var e, n = 1, r = arguments.length; n < r; n++) for (var o in e = arguments[n]) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
return t;
}).apply(this, arguments);
};
var E,
k = function () {
function t(t, e) {
void 0 === e && (e = {}), this.reportOptions = {}, this.config = t, this.reportOptions = e;
}
return t.canUseDB = function () {
return !!(null === window || void 0 === window ? void 0 : window.indexedDB);
}, t.prototype.openDB = function () {
var e = this;
return new Promise(function (n, r) {
if (!t.canUseDB()) return r({
message: "当前不支持 indexeddb"
});
var o = e.config,
i = o.name,
s = o.version,
a = o.stores,
u = indexedDB.open(i, s);
u.onsuccess = function () {
e.db = u.result, n(), _I({
result: 1,
func: "open",
params: JSON.stringify(e.config)
}, e.reportOptions);
}, u.onerror = function (t) {
var n, o;
r(t), _I({
result: 0,
func: "open",
params: JSON.stringify(e.config),
error_msg: null === (o = null === (n = t.target) || void 0 === n ? void 0 : n.error) || void 0 === o ? void 0 : o.message
}, e.reportOptions);
}, u.onupgradeneeded = function () {
e.db = u.result;
try {
null == a || a.forEach(function (t) {
e.createStore(t);
});
} catch (t) {
_I({
result: 0,
func: "open",
params: JSON.stringify(e.config),
error_msg: t.message
}, e.reportOptions), r(t);
}
};
});
}, t.prototype.useStore = function (t) {
return this.storeName = t, this;
}, t.prototype.deleteDB = function () {
var t = this;
return this.closeDB(), new Promise(function (e, n) {
var r = indexedDB.deleteDatabase(t.config.name);
r.onsuccess = function () {
return e();
}, r.onerror = n;
});
}, t.prototype.closeDB = function () {
var t;
null === (t = this.db) || void 0 === t || t.close(), this.db = null;
}, t.prototype.getStoreCount = function () {
var t = this;
return new Promise(function (e, n) {
var r = t.getStore("readonly").count();
r.onsuccess = function () {
return e(r.result);
}, r.onerror = n;
});
}, t.prototype.clearStore = function () {
var t = this;
return new Promise(function (e, n) {
var r = t.getStore("readwrite").clear();
r.onsuccess = function () {
return e();
}, r.onerror = n;
});
}, t.prototype.add = function (t, e) {
var n = this;
return new Promise(function (r, o) {
var i = n.getStore("readwrite").add(t, e);
i.onsuccess = function () {
r(i.result);
}, i.onerror = o;
});
}, t.prototype.put = function (t, e) {
var n = this;
return new Promise(function (r, o) {
var i = n.getStore("readwrite").put(t, e);
i.onsuccess = function () {
r(i.result);
}, i.onerror = o;
});
}, t.prototype.getStoreAllData = function () {
var t = this;
return new Promise(function (e, n) {
var r = t.getStore("readonly").openCursor(),
o = [];
r.onsuccess = function () {
var t;
if (null === (t = r.result) || void 0 === t ? void 0 : t.value) {
var n = r.result.value;
o.push(n), r.result.continue();
} else e(o);
}, r.onerror = n;
});
}, t.prototype.getDataRangeByIndex = function (t, e, n, r, o) {
var i = this;
return new Promise(function (s, a) {
var u = i.getStore().index(t),
c = IDBKeyRange.bound(e, n, r, o),
l = [],
p = u.openCursor(c);
p.onsuccess = function () {
var t;
(null === (t = null == p ? void 0 : p.result) || void 0 === t ? void 0 : t.value) ? (l.push(null == p ? void 0 : p.result.value), null == p || p.result.continue()) : s(l);
}, p.onerror = a;
});
}, t.prototype.removeDataByIndex = function (t, e, n, r, o) {
var i = this;
return new Promise(function (s, a) {
var u = i.getStore("readwrite").index(t),
c = IDBKeyRange.bound(e, n, r, o),
l = u.openCursor(c),
p = 0;
l.onsuccess = function (t) {
var e = t.target.result;
e ? (p += 1, e.delete(), e.continue()) : s(p);
}, l.onerror = a;
});
}, t.prototype.createStore = function (t) {
var e = t.name,
n = t.indexes,
r = void 0 === n ? [] : n,
o = t.options;
if (this.db) {
this.db.objectStoreNames.contains(e) && this.db.deleteObjectStore(e);
var i = this.db.createObjectStore(e, o);
r.forEach(function (t) {
i.createIndex(t.indexName, t.keyPath, t.options);
});
}
}, t.prototype.getStore = function (t) {
var e;
return void 0 === t && (t = "readonly"), null === (e = this.db) || void 0 === e ? void 0 : e.transaction(this.storeName, t).objectStore(this.storeName);
}, t;
}(),
O = "event_table_v3",
C = "eventId",
D = function () {
function t(t) {
this.isReady = !1, this.taskQueue = Promise.resolve(), this.db = new k({
name: "Beacon_" + t + "_V3",
version: 1,
stores: [{
name: O,
options: {
keyPath: C
},
indexes: [{
indexName: C,
keyPath: C,
options: {
unique: !0
}
}]
}]
}), this.open();
}
return t.prototype.getCount = function () {
var t = this;
return this.readyExec(function () {
return t.db.getStoreCount();
});
}, t.prototype.setItem = function (t, e) {
var n = this;
return this.readyExec(function () {
return n.db.add({
eventId: t,
value: e
});
});
}, t.prototype.getItem = function (t) {
return n(this, void 0, void 0, function () {
var e = this;
return r(this, function (n) {
return [2, this.readyExec(function () {
return e.db.getDataRangeByIndex(C, t, t);
})];
});
});
}, t.prototype.removeItem = function (t) {
var e = this;
return this.readyExec(function () {
return e.db.removeDataByIndex(C, t, t);
});
}, t.prototype.updateItem = function (t, e) {
var n = this;
return this.readyExec(function () {
return n.db.put({
eventId: t,
value: e
});
});
}, t.prototype.iterate = function (t) {
var e = this;
return this.readyExec(function () {
return e.db.getStoreAllData().then(function (e) {
e.forEach(function (e) {
t(e.value);
});
});
});
}, t.prototype.open = function () {
return n(this, void 0, void 0, function () {
var t = this;
return r(this, function (e) {
switch (e.label) {
case 0:
return this.taskQueue = this.taskQueue.then(function () {
return t.db.openDB();
}), [4, this.taskQueue];
case 1:
return e.sent(), this.isReady = !0, this.db.useStore(O), [2];
}
});
});
}, t.prototype.readyExec = function (t) {
return this.isReady ? t() : (this.taskQueue = this.taskQueue.then(function () {
return t();
}), this.taskQueue);
}, t;
}(),
x = function () {
function t(t) {
this.keyObject = {}, this.storage = t;
}
return t.prototype.getCount = function () {
return this.storage.getStoreCount();
}, t.prototype.removeItem = function (t) {
this.storage.removeItem(t), delete this.keyObject[t];
}, t.prototype.setItem = function (t, e) {
var n = JSON.stringify(e);
this.storage.setItem(t, n), this.keyObject[t] = e;
}, t.prototype.iterate = function (t) {
for (var e = Object.keys(this.keyObject), n = 0; n < e.length; n++) {
var r = this.storage.getItem(e[n]);
t(JSON.parse(r));
}
}, t;
}(),
_ = function () {
function t(t, e) {
var n = this;
this.dbEventCount = 0, b() > 0 || !window.indexedDB || /X5Lite/.test(navigator.userAgent) ? (this.store = new x(e), this.dbEventCount = this.store.getCount()) : (this.store = new D(t), this.getCount().then(function (t) {
n.dbEventCount = t;
}).catch(function (t) {}));
}
return t.prototype.getCount = function () {
return n(this, void 0, void 0, function () {
return r(this, function (t) {
switch (t.label) {
case 0:
return t.trys.push([0, 2,, 3]), [4, this.store.getCount()];
case 1:
return [2, t.sent()];
case 2:
return t.sent(), [2, Promise.reject()];
case 3:
return [2];
}
});
});
}, t.prototype.insertEvent = function (t, e) {
return n(this, void 0, void 0, function () {
var n, o;
return r(this, function (r) {
switch (r.label) {
case 0:
if (this.dbEventCount >= 1e4) return [2, Promise.reject()];
n = f(t.mapValue), r.label = 1;
case 1:
return r.trys.push([1, 3,, 4]), this.dbEventCount++, [4, this.store.setItem(n, t)];
case 2:
return [2, r.sent()];
case 3:
return o = r.sent(), e && e(o, t), this.dbEventCount--, [2, Promise.reject()];
case 4:
return [2];
}
});
});
}, t.prototype.getEvents = function () {
return n(this, void 0, void 0, function () {
var t;
return r(this, function (e) {
switch (e.label) {
case 0:
t = [], e.label = 1;
case 1:
return e.trys.push([1, 3,, 4]), [4, this.store.iterate(function (e) {
t.push(e);
})];
case 2:
return e.sent(), [2, Promise.all(t)];
case 3:
return e.sent(), [2, Promise.all(t)];
case 4:
return [2];
}
});
});
}, t.prototype.removeEvent = function (t) {
return n(this, void 0, void 0, function () {
var e;
return r(this, function (n) {
switch (n.label) {
case 0:
e = f(t.mapValue), n.label = 1;
case 1:
return n.trys.push([1, 3,, 4]), this.dbEventCount--, [4, this.store.removeItem(e)];
case 2:
return [2, n.sent()];
case 3:
return n.sent(), this.dbEventCount++, [2, Promise.reject()];
case 4:
return [2];
}
});
});
}, t;
}(),
_P = function P() {
return (_P = Object.assign || function (t) {
for (var e, n = 1, r = arguments.length; n < r; n++) for (var o in e = arguments[n]) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
return t;
}).apply(this, arguments);
};
function T(t) {
try {
return decodeURIComponent(t.replace(/\+/g, " "));
} catch (t) {
return null;
}
}
function U(t, e) {
var n = [null, void 0, "", NaN].includes(t);
if (e.isSkipEmpty && n) return null;
var r = !e.isSkipEmpty && n ? "" : t;
try {
return e.encode ? encodeURIComponent(r) : r;
} catch (t) {
return null;
}
}
function N(t, e) {
void 0 === e && (e = {
encode: !0,
isSkipEmpty: !1
});
var n = t.url,
r = t.query,
o = void 0 === r ? {} : r,
i = t.hash,
s = n.split("#"),
a = s[0],
u = s[1],
c = void 0 === u ? "" : u,
l = a.split("?")[0],
p = [],
h = U(i || c, e),
f = _P(_P({}, function (t) {
var e = t.split("#"),
n = e[0],
r = e[1],
o = void 0 === r ? "" : r,
i = n.split("?"),
s = i[0],
a = i[1],
u = void 0 === a ? "" : a,
c = T(o),
l = Object.create(null);
return u.split("&").forEach(function (t) {
var e = t.split("="),
n = e[0],
r = e[1],
o = void 0 === r ? "" : r,
i = T(n),
s = T(o);
null === i || null === s || "" === i && "" === s || l[i] || (l[i] = s);
}), {
url: s,
query: l,
hash: c
};
}(n).query), o);
return Object.keys(f).forEach(function (t) {
var n = U(t, e),
r = U(f[t], e);
null !== n && null !== r && p.push(n + "=" + r);
}), l + (p.length ? "?" + p.join("&") : "") + (h ? "#" + h : "");
}
function j(t, e) {
return new Promise(function (n, r) {
if (e && document.querySelectorAll("script[data-tag=" + e + "]").length) return n();
var o = document.createElement("script"),
i = _P({
type: "text/javascript",
charset: "utf-8"
}, t);
Object.keys(i).forEach(function (t) {
return function (t, e, n) {
if (t) return void 0 === n ? t.getAttribute(e) : t.setAttribute(e, n);
}(o, t, i[t]);
}), e && (o.dataset.tag = e), o.onload = function () {
return n();
}, o.onreadystatechange = function () {
var t = o.readyState;
["complete", "loaded"].includes(t) && (o.onreadystatechange = null, n());
}, o.onerror = r, document.body.appendChild(o);
});
}
!function (t) {
t[t.equal = 0] = "equal", t[t.low = -1] = "low", t[t.high = 1] = "high";
}(E || (E = {}));
var _q = function q() {
return (_q = Object.assign || function (t) {
for (var e, n = 1, r = arguments.length; n < r; n++) for (var o in e = arguments[n]) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
return t;
}).apply(this, arguments);
};
function A(t, e, n, r) {
return new (n || (n = Promise))(function (o, i) {
function s(t) {
try {
u(r.next(t));
} catch (t) {
i(t);
}
}
function a(t) {
try {
u(r.throw(t));
} catch (t) {
i(t);
}
}
function u(t) {
var e;
t.done ? o(t.value) : (e = t.value, e instanceof n ? e : new n(function (t) {
t(e);
})).then(s, a);
}
u((r = r.apply(t, e || [])).next());
});
}
function R(t, e) {
var n,
r,
o,
i,
s = {
label: 0,
sent: function sent() {
if (1 & o[0]) throw o[1];
return o[1];
},
trys: [],
ops: []
};
return i = {
next: a(0),
throw: a(1),
return: a(2)
}, "function" == typeof Symbol && (i[Symbol.iterator] = function () {
return this;
}), i;
function a(i) {
return function (a) {
return function (i) {
if (n) throw new TypeError("Generator is already executing.");
for (; s;) try {
if (n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o;
switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) {
case 0:
case 1:
o = i;
break;
case 4:
return s.label++, {
value: i[1],
done: !1
};
case 5:
s.label++, r = i[1], i = [0];
continue;
case 7:
i = s.ops.pop(), s.trys.pop();
continue;
default:
if (!((o = (o = s.trys).length > 0 && o[o.length - 1]) || 6 !== i[0] && 2 !== i[0])) {
s = 0;
continue;
}
if (3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) {
s.label = i[1];
break;
}
if (6 === i[0] && s.label < o[1]) {
s.label = o[1], o = i;
break;
}
if (o && s.label < o[2]) {
s.label = o[2], s.ops.push(i);
break;
}
o[2] && s.ops.pop(), s.trys.pop();
continue;
}
i = e.call(t, s);
} catch (t) {
i = [6, t], r = 0;
} finally {
n = o = 0;
}
if (5 & i[0]) throw i[1];
return {
value: i[0] ? i[1] : void 0,
done: !0
};
}([i, a]);
};
}
}
var B = function () {
function t() {
this.interceptors = [];
}
return t.prototype.use = function (t, e) {
return this.interceptors.push({
resolved: t,
rejected: e
}), this.interceptors.length - 1;
}, t.prototype.traverse = function (t, e) {
void 0 === e && (e = !1);
var n = Promise.resolve(t);
return (e ? Array.prototype.reduceRight : Array.prototype.reduce).call(this.interceptors, function (t, e) {
if (e) {
var r = e.resolved,
o = e.rejected;
n = n.then(r, o);
}
return t;
}, ""), n;
}, t.prototype.eject = function (t) {
this.interceptors[t] && (this.interceptors[t] = null);
}, t;
}(),
J = {
defaults: {
timeout: 0,
method: "GET",
mode: "cors",
redirect: "follow",
credentials: "same-origin"
},
headers: {
common: {
Accept: "application/json, text/plain, */*"
},
POST: {
"Content-Type": "application/x-www-form-urlencoded"
},
PUT: {
"Content-Type": "application/x-www-form-urlencoded"
},
PATCH: {
"Content-Type": "application/x-www-form-urlencoded"
}
},
baseURL: "",
polyfillUrl: "https://vm.gtimg.cn/comps/script/fetch.min.js",
interceptors: {
request: new B(),
response: new B()
}
},
V = /^([a-z][a-z\d+\-.]*:)?\/\//i,
Q = Object.prototype.toString;
function L(t) {
return A(this, void 0, void 0, function () {
var e;
return R(this, function (n) {
switch (n.label) {
case 0:
if (window.fetch) return [2];
n.label = 1;
case 1:
return n.trys.push([1, 3,, 4]), [4, j({
src: t
})];
case 2:
return n.sent(), [3, 4];
case 3:
throw e = n.sent(), new Error("加载 polyfill " + t + " 失败: " + e.message);
case 4:
return [2];
}
});
});
}
function M(t) {
return ["Accept", "Content-Type"].forEach(function (e) {
return n = e, void ((r = t.headers) && Object.keys(r).forEach(function (t) {
t !== n && t.toUpperCase() === n.toUpperCase() && (r[n] = r[t], delete r[t]);
}));
var n, r;
}), function (t) {
if ("[object Object]" !== Q.call(t)) return !1;
var e = Object.getPrototypeOf(t);
return null === e || e === Object.prototype;
}(t.body) && (t.body = JSON.stringify(t.body), t.headers && (t.headers["Content-Type"] = "application/json;charset=utf-8")), t;
}
function K(t) {
return A(this, void 0, void 0, function () {
var e, n, r, o, i, s, a, u, c, l, p, h, f, d, v, g, y;
return R(this, function (m) {
switch (m.label) {
case 0:
return e = J.baseURL, n = J.defaults, r = J.interceptors, [4, L(J.polyfillUrl)];
case 1:
return m.sent(), (o = _q(_q({}, n), t)).headers || (o.headers = function (t) {
void 0 === t && (t = "GET");
var e = J.headers[t] || {};
return _q(_q({}, J.headers.common), e);
}(o.method)), M(o), [4, r.request.traverse(o, !0)];
case 2:
if ((i = m.sent()) instanceof Error) throw i;
return i.url = function (t, e) {
return !t || V.test(e) ? e : t.replace(/\/+$/, "") + "/" + e.replace(/^\/+/, "");
}(e, i.url), s = i.url, a = i.timeout, u = i.params, c = i.method, l = ["GET", "DELETE", "OPTIONS", "HEAD"].includes(void 0 === c ? "GET" : c) && !!u, p = l ? N({
url: s,
query: u
}) : s, h = [], a && !i.signal && (v = new Promise(function (t) {
f = setTimeout(function () {
t(new Error("timeout"));
}, a);
}), h.push(v), d = new AbortController(), i.signal = d.signal), h.push(fetch(p, i).catch(function (t) {
return t;
})), [4, Promise.race(h)];
case 3:
return g = m.sent(), f && clearTimeout(f), [4, r.response.traverse(g)];
case 4:
if ((y = m.sent()) instanceof Error) throw null == d || d.abort(), y;
return [2, y];
}
});
});
}
var F = function () {
function t(t) {
J.interceptors.request.use(function (n) {
var r = n.url,
o = n.method,
i = n.body,
s = i;
if (t.onReportBeforeSend) {
var a = t.onReportBeforeSend({
url: r,
method: o,
data: i ? JSON.parse(i) : null
});
s = (null == a ? void 0 : a.data) ? JSON.stringify(a.data) : null;
}
return "GET" != o && s ? _e(_e({}, n), {
body: s
}) : n;
});
}
return t.prototype.get = function (t, o) {
return n(this, void 0, void 0, function () {
var n, i;
return r(this, function (r) {
switch (r.label) {
case 0:
return [4, K(_e({
url: t
}, o))];
case 1:
return [4, (n = r.sent()).json()];
case 2:
return i = r.sent(), [2, Promise.resolve({
data: i,
status: n.status,
statusText: n.statusText,
headers: n.headers
})];
}
});
});
}, t.prototype.post = function (t, o, i) {
return n(this, void 0, void 0, function () {
var n, s;
return r(this, function (r) {
switch (r.label) {
case 0:
return [4, K(_e({
url: t,
body: o,
method: "POST"
}, i))];
case 1:
return [4, (n = r.sent()).json()];
case 2:
return s = r.sent(), [2, Promise.resolve({
data: s,
status: n.status,
statusText: n.statusText,
headers: n.headers
})];
}
});
});
}, t;
}(),
G = function () {
function t(t) {
this.appkey = t;
}
return t.prototype.getItem = function (t) {