|
@@ -855,6 +855,41 @@
|
|
|
c = (n < 10 ? "0" : "") + n,
|
|
|
h = (o < 10 ? "0" : "") + o;
|
|
|
return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
|
|
|
+ },
|
|
|
+
|
|
|
+ createInstance(i) {
|
|
|
+ var e = new Axios(i),
|
|
|
+ t = bind(Axios.prototype.request, e);
|
|
|
+ return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
|
|
|
+ return createInstance(mergeConfig(i, n));
|
|
|
+ }, t;
|
|
|
+ },
|
|
|
+
|
|
|
+ mapLimit(i, e, t) {
|
|
|
+ return new Promise(function (r, n) {
|
|
|
+ var o = i.length;
|
|
|
+ var a = e - 1,
|
|
|
+ s = 0;
|
|
|
+
|
|
|
+ var l = function l(u) {
|
|
|
+ u.forEach(function (c) {
|
|
|
+ t(c).then(function () {
|
|
|
+ if (s++, s === o) {
|
|
|
+ r();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ a++;
|
|
|
+ var h = i[a];
|
|
|
+ h && l([h]);
|
|
|
+ }, function (h) {
|
|
|
+ n(h);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ l(i.slice(0, e));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
};
|
|
@@ -921,14 +956,14 @@
|
|
|
return _getPrototypeOf(o);
|
|
|
}
|
|
|
|
|
|
- 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 _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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; } }
|
|
|
+ function _isNativeReflectConstruct$2() { 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 Reporter = /*#__PURE__*/function (_EventEmitter) {
|
|
|
_inherits(Reporter, _EventEmitter);
|
|
|
|
|
|
- var _super = _createSuper(Reporter);
|
|
|
+ var _super = _createSuper$2(Reporter);
|
|
|
|
|
|
function Reporter() {
|
|
|
var _this;
|
|
@@ -1071,7 +1106,7 @@
|
|
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
|
}
|
|
|
|
|
|
- var Codes$1 = {
|
|
|
+ var Codes = {
|
|
|
Success: 0,
|
|
|
Param: 1001,
|
|
|
Internal: 1002,
|
|
@@ -1202,7 +1237,7 @@
|
|
|
e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
|
|
|
}
|
|
|
|
|
|
- if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes$1.Internal : e.code = Codes$1.Success, reporter.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) {
|
|
|
+ if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes.Internal : e.code = Codes.Success, reporter.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) {
|
|
|
this.error.apply(this, _toConsumableArray(t));
|
|
|
return;
|
|
|
}
|
|
@@ -1243,6 +1278,236 @@
|
|
|
}();
|
|
|
var logger = new Logger$1();
|
|
|
|
|
|
+ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); 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$1() { 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 Http = /*#__PURE__*/function (_EventEmitter) {
|
|
|
+ _inherits(Http, _EventEmitter);
|
|
|
+
|
|
|
+ var _super = _createSuper$1(Http);
|
|
|
+
|
|
|
+ function Http() {
|
|
|
+ _classCallCheck(this, Http);
|
|
|
+
|
|
|
+ return _super.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ _createClass(Http, [{
|
|
|
+ key: "get",
|
|
|
+ value: function () {
|
|
|
+ var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
|
|
|
+ var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
|
|
|
+
|
|
|
+ return regenerator.wrap(function _callee2$(_context2) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context2.prev = _context2.next) {
|
|
|
+ case 0:
|
|
|
+ e = _ref.url, _ref$useIndexedDb = _ref.useIndexedDb, t = _ref$useIndexedDb === void 0 ? !1 : _ref$useIndexedDb, _ref$timeout = _ref.timeout, r = _ref$timeout === void 0 ? 15e3 : _ref$timeout, n = _ref.key, _ref$isOutPutObjectUR = _ref.isOutPutObjectURL, o = _ref$isOutPutObjectUR === void 0 ? !0 : _ref$isOutPutObjectUR;
|
|
|
+
|
|
|
+ if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
|
|
|
+ _context2.next = 25;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isIndexedDbSupported()) {
|
|
|
+ _context2.next = 22;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ window.performance.now();
|
|
|
+ a = null;
|
|
|
+ _context2.prev = 5;
|
|
|
+ _context2.next = 8;
|
|
|
+ return modelTable.query("url", e);
|
|
|
+
|
|
|
+ case 8:
|
|
|
+ a = _context2.sent;
|
|
|
+ _context2.next = 14;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 11:
|
|
|
+ _context2.prev = 11;
|
|
|
+ _context2.t0 = _context2["catch"](5);
|
|
|
+ return _context2.abrupt("return", (logger.debug(_context2.t0), logger.warn("cache query error", e), Promise.resolve(e)));
|
|
|
+
|
|
|
+ case 14:
|
|
|
+ if (!(a && a.model)) {
|
|
|
+ _context2.next = 19;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
|
|
|
+ return _context2.abrupt("return", (window.performance.now(), l));
|
|
|
+
|
|
|
+ case 19:
|
|
|
+ return _context2.abrupt("return", this.request({
|
|
|
+ url: e,
|
|
|
+ timeout: r,
|
|
|
+ contentType: "blob",
|
|
|
+ key: n
|
|
|
+ }).then( /*#__PURE__*/function () {
|
|
|
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
|
|
|
+ var l;
|
|
|
+ return regenerator.wrap(function _callee$(_context) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context.prev = _context.next) {
|
|
|
+ case 0:
|
|
|
+ _context.next = 2;
|
|
|
+ return blobToDataURI(s.response);
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ l = _context.sent;
|
|
|
+ _context.prev = 3;
|
|
|
+ _context.next = 6;
|
|
|
+ return modelTable.put({
|
|
|
+ url: e,
|
|
|
+ model: l
|
|
|
+ });
|
|
|
+
|
|
|
+ case 6:
|
|
|
+ _context.next = 11;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 8:
|
|
|
+ _context.prev = 8;
|
|
|
+ _context.t0 = _context["catch"](3);
|
|
|
+ logger.warn("unable to add data to indexedDB", _context.t0);
|
|
|
+
|
|
|
+ case 11:
|
|
|
+ return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
|
|
|
+
|
|
|
+ case 12:
|
|
|
+ case "end":
|
|
|
+ return _context.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee, null, [[3, 8]]);
|
|
|
+ }));
|
|
|
+
|
|
|
+ return function (_x2) {
|
|
|
+ return _ref2.apply(this, arguments);
|
|
|
+ };
|
|
|
+ }()));
|
|
|
+
|
|
|
+ case 20:
|
|
|
+ _context2.next = 23;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 22:
|
|
|
+ return _context2.abrupt("return", this.request({
|
|
|
+ url: e,
|
|
|
+ timeout: r,
|
|
|
+ contentType: "blob",
|
|
|
+ key: n
|
|
|
+ }).then(function (a) {
|
|
|
+ var s = a.response;
|
|
|
+ return Promise.resolve(o ? URL.createObjectURL(s) : s);
|
|
|
+ }).catch(function (a) {
|
|
|
+ return Promise.reject(a);
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 23:
|
|
|
+ _context2.next = 26;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 25:
|
|
|
+ return _context2.abrupt("return", this.request({
|
|
|
+ url: e,
|
|
|
+ timeout: r,
|
|
|
+ key: n
|
|
|
+ }).then(function (a) {
|
|
|
+ return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 26:
|
|
|
+ case "end":
|
|
|
+ return _context2.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee2, this, [[5, 11]]);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function get(_x) {
|
|
|
+ return _get.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return get;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "request",
|
|
|
+ value: function request(e) {
|
|
|
+ var _this = this;
|
|
|
+
|
|
|
+ var _e$timeout = e.timeout,
|
|
|
+ t = _e$timeout === void 0 ? 3e4 : _e$timeout,
|
|
|
+ r = e.contentType;
|
|
|
+ e.key;
|
|
|
+ var o = e.onRequestStart,
|
|
|
+ a = e.url;
|
|
|
+ return new Promise(function (s, l) {
|
|
|
+ window.performance.now();
|
|
|
+ var u = new XMLHttpRequest();
|
|
|
+ r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
|
|
|
+ if (u.readyState == 4) {
|
|
|
+ if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
|
|
|
+ message: "request ".concat(a, " load success")
|
|
|
+ }), s(u);
|
|
|
+ {
|
|
|
+ var c = "Unable to load the request ".concat(a);
|
|
|
+ return _this.emit("error", {
|
|
|
+ message: c
|
|
|
+ }), logger.error(c), l(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }), o && o(u), u.open("GET", a), u.send();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ return Http;
|
|
|
+ }(EventEmitter);
|
|
|
+
|
|
|
+ var http = new Http();
|
|
|
+ // , isIndexedDbSupported = ()=>(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0
|
|
|
+ // , blobToDataURI = async i=>new Promise((e,t)=>{
|
|
|
+ // const r = new FileReader;
|
|
|
+ // r.readAsDataURL(i),
|
|
|
+ // r.onload = function(n) {
|
|
|
+ // var o;
|
|
|
+ // e((o = n.target) == null ? void 0 : o.result)
|
|
|
+ // }
|
|
|
+ // ,
|
|
|
+ // r.onerror = function(n) {
|
|
|
+ // t(n)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // , dataURItoBlob = i=>{
|
|
|
+ // let e;
|
|
|
+ // i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
|
|
|
+ // const t = i.split(",")[0].split(":")[1].split(";")[0]
|
|
|
+ // , r = new Uint8Array(e.length);
|
|
|
+ // for (let o = 0; o < e.length; o++)
|
|
|
+ // r[o] = e.charCodeAt(o);
|
|
|
+ // return new Blob([r],{
|
|
|
+ // type: t
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // , urlMap = new Map
|
|
|
+ // , urlTransformer = async(i,e=!1)=>typeof i != "string" ? (console.warn("url transformer error", i),
|
|
|
+ // i) : i.startsWith("blob:") ? i : e ? http.get({
|
|
|
+ // url: i,
|
|
|
+ // useIndexedDb: !0,
|
|
|
+ // key: "url",
|
|
|
+ // isOutPutObjectURL: !1
|
|
|
+ // }) : urlMap.has(i) ? urlMap.get(i) : http.get({
|
|
|
+ // url: i,
|
|
|
+ // useIndexedDb: !0,
|
|
|
+ // key: "url"
|
|
|
+ // }).then(t=>(urlMap.set(i, t),
|
|
|
+ // t));
|
|
|
+
|
|
|
var ModelManager = /*#__PURE__*/function () {
|
|
|
function ModelManager(e, t) {
|
|
|
_classCallCheck(this, ModelManager);
|
|
@@ -1486,7 +1751,7 @@
|
|
|
key: "requestConfig",
|
|
|
value: function () {
|
|
|
var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
|
|
|
- var e, t, r, _ref, n, o;
|
|
|
+ var t, r, _ref, n, o;
|
|
|
|
|
|
return regenerator.wrap(function _callee6$(_context6) {
|
|
|
while (1) {
|
|
@@ -1500,48 +1765,49 @@
|
|
|
return _context6.abrupt("return", this.config);
|
|
|
|
|
|
case 2:
|
|
|
- e = "https://static.xverse.cn/console/config/".concat(this.appId, "/config.json");
|
|
|
- this.releaseId && (e = "https://static.xverse.cn/console/config/".concat(this.appId, "/").concat(this.releaseId, "/config.json"));
|
|
|
- t = Xverse$1.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
|
|
|
- _context6.prev = 5;
|
|
|
- _context6.next = 8;
|
|
|
- return http$1.get({
|
|
|
+ // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
|
|
|
+ // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
|
|
|
+ // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
|
|
|
+ t = './assets/config.json';
|
|
|
+ _context6.prev = 3;
|
|
|
+ _context6.next = 6;
|
|
|
+ return http.get({
|
|
|
url: "".concat(t, "?t=").concat(Date.now()),
|
|
|
key: "config",
|
|
|
timeout: 6e3,
|
|
|
retry: 2
|
|
|
});
|
|
|
|
|
|
- case 8:
|
|
|
+ case 6:
|
|
|
r = _context6.sent;
|
|
|
- _ref = r.data.data || {};
|
|
|
+ _ref = JSON.parse(r).data || {};
|
|
|
n = _ref.config;
|
|
|
o = _ref.preload;
|
|
|
|
|
|
if (n) {
|
|
|
- _context6.next = 14;
|
|
|
+ _context6.next = 12;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
throw new Error("config data parse error" + r.data);
|
|
|
|
|
|
- case 14:
|
|
|
+ case 12:
|
|
|
return _context6.abrupt("return", (this.config = {
|
|
|
config: n,
|
|
|
preload: o
|
|
|
}, logger.debug("get config success", this.config), this.config));
|
|
|
|
|
|
- case 17:
|
|
|
- _context6.prev = 17;
|
|
|
- _context6.t0 = _context6["catch"](5);
|
|
|
+ case 15:
|
|
|
+ _context6.prev = 15;
|
|
|
+ _context6.t0 = _context6["catch"](3);
|
|
|
return _context6.abrupt("return", Promise.reject(_context6.t0));
|
|
|
|
|
|
- case 20:
|
|
|
+ case 18:
|
|
|
case "end":
|
|
|
return _context6.stop();
|
|
|
}
|
|
|
}
|
|
|
- }, _callee6, this, [[5, 17]]);
|
|
|
+ }, _callee6, this, [[3, 15]]);
|
|
|
}));
|
|
|
|
|
|
function requestConfig() {
|
|
@@ -1810,6 +2076,372 @@
|
|
|
}();
|
|
|
// export { modelManager };
|
|
|
|
|
|
+ var BaseTable = /*#__PURE__*/function () {
|
|
|
+ function BaseTable(e, t) {
|
|
|
+ _classCallCheck(this, BaseTable);
|
|
|
+
|
|
|
+ this.db = null;
|
|
|
+ this.isCreatingTable = !1;
|
|
|
+ this.hasCleared = !1;
|
|
|
+ this.dbName = e, this.dbVersion = t;
|
|
|
+ }
|
|
|
+
|
|
|
+ _createClass(BaseTable, [{
|
|
|
+ key: "clearDataBase",
|
|
|
+ value: function () {
|
|
|
+ var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
|
|
|
+ var _this = this;
|
|
|
+
|
|
|
+ return regenerator.wrap(function _callee$(_context) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context.prev = _context.next) {
|
|
|
+ case 0:
|
|
|
+ return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
|
|
|
+ var n = window.indexedDB.deleteDatabase(_this.dbName);
|
|
|
+ n.onsuccess = function () {
|
|
|
+ t();
|
|
|
+ }, n.onerror = r;
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ case "end":
|
|
|
+ return _context.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function clearDataBase(_x) {
|
|
|
+ return _clearDataBase.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return clearDataBase;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "tableName",
|
|
|
+ value: function tableName() {
|
|
|
+ throw new Error("Derived class have to override 'tableName', and set a proper table name!");
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "keyPath",
|
|
|
+ value: function keyPath() {
|
|
|
+ throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "index",
|
|
|
+ value: function index() {
|
|
|
+ throw new Error("Derived class have to override 'index', and set a proper index name!");
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "checkAndOpenDatabase",
|
|
|
+ value: function () {
|
|
|
+ var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
|
+ var _this2 = this;
|
|
|
+
|
|
|
+ return regenerator.wrap(function _callee2$(_context2) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context2.prev = _context2.next) {
|
|
|
+ case 0:
|
|
|
+ return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
|
|
|
+ var n = setTimeout(function () {
|
|
|
+ logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
|
|
|
+ }, 200);
|
|
|
+
|
|
|
+ _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
|
|
|
+ _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
|
|
|
+ }, function () {
|
|
|
+ t(new Error("Failed to open database!")), clearTimeout(n);
|
|
|
+ }, function () {
|
|
|
+ _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
|
|
|
+ });
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ case "end":
|
|
|
+ return _context2.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee2, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function checkAndOpenDatabase() {
|
|
|
+ return _checkAndOpenDatabase.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return checkAndOpenDatabase;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "openDatabase",
|
|
|
+ value: function openDatabase(e, t, r, n, o) {
|
|
|
+ var _this3 = this;
|
|
|
+
|
|
|
+ if (this.isCreatingTable) return;
|
|
|
+ this.isCreatingTable = !0, logger.info(e, t);
|
|
|
+ var a = window.indexedDB.open(e, t),
|
|
|
+ s = this.tableName();
|
|
|
+ a.onsuccess = function (l) {
|
|
|
+ _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
|
|
|
+ }, a.onerror = function (l) {
|
|
|
+ var u;
|
|
|
+ logger.error("Failed to open database", (u = l == null ? void 0 : l.srcElement) == null ? void 0 : u.error), _this3.isCreatingTable = !1, n && n(l), _this3.clearDataBase(!0);
|
|
|
+ }, a.onupgradeneeded = function (l) {
|
|
|
+ var u = l.target.result,
|
|
|
+ c = _this3.index();
|
|
|
+
|
|
|
+ logger.info("Creating table ".concat(s, "."));
|
|
|
+ var h = u.objectStoreNames.contains(s);
|
|
|
+ if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
|
|
|
+ var f = _this3.keyPath();
|
|
|
+
|
|
|
+ h = u.createObjectStore(s, {
|
|
|
+ keyPath: f
|
|
|
+ });
|
|
|
+ }
|
|
|
+ c.map(function (f) {
|
|
|
+ h.createIndex(f, f, {
|
|
|
+ unique: !1
|
|
|
+ });
|
|
|
+ }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "add",
|
|
|
+ value: function () {
|
|
|
+ var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
|
|
|
+ var t, o;
|
|
|
+ return regenerator.wrap(function _callee3$(_context3) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context3.prev = _context3.next) {
|
|
|
+ case 0:
|
|
|
+ t = this.tableName();
|
|
|
+ _context3.next = 3;
|
|
|
+ return this.checkAndOpenDatabase();
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
|
|
|
+ return _context3.abrupt("return", new Promise(function (a, s) {
|
|
|
+ o.onsuccess = function (l) {
|
|
|
+ a(l);
|
|
|
+ }, o.onerror = function (l) {
|
|
|
+ var u;
|
|
|
+ logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
|
|
|
+ };
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ case "end":
|
|
|
+ return _context3.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee3, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function add(_x2) {
|
|
|
+ return _add.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return add;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "put",
|
|
|
+ value: function () {
|
|
|
+ var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
|
|
|
+ var t, o;
|
|
|
+ return regenerator.wrap(function _callee4$(_context4) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context4.prev = _context4.next) {
|
|
|
+ case 0:
|
|
|
+ t = this.tableName();
|
|
|
+ _context4.next = 3;
|
|
|
+ return this.checkAndOpenDatabase();
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
|
|
|
+ return _context4.abrupt("return", new Promise(function (a, s) {
|
|
|
+ o.onsuccess = function (l) {
|
|
|
+ a(l);
|
|
|
+ }, o.onerror = function (l) {
|
|
|
+ var u;
|
|
|
+ logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
|
|
|
+ };
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ case "end":
|
|
|
+ return _context4.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee4, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function put(_x3) {
|
|
|
+ return _put.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return put;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "delete",
|
|
|
+ value: function _delete(e, t, r) {
|
|
|
+ var n = this.tableName();
|
|
|
+ this.checkAndOpenDatabase().then(function (o) {
|
|
|
+ var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
|
|
|
+ s.onsuccess = t, s.onerror = r;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "update",
|
|
|
+ value: function update() {
|
|
|
+ this.checkAndOpenDatabase().then(function (e) {});
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "getAllKeys",
|
|
|
+ value: function () {
|
|
|
+ var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
|
|
|
+ var e, t;
|
|
|
+ return regenerator.wrap(function _callee5$(_context5) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context5.prev = _context5.next) {
|
|
|
+ case 0:
|
|
|
+ e = this.tableName();
|
|
|
+ _context5.next = 3;
|
|
|
+ return this.checkAndOpenDatabase();
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ t = _context5.sent;
|
|
|
+ return _context5.abrupt("return", new Promise(function (r, n) {
|
|
|
+ var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
|
|
|
+ a.onsuccess = function (s) {
|
|
|
+ r(s.target.result);
|
|
|
+ }, a.onerror = function (s) {
|
|
|
+ logger.error("db getAllKeys error", s), n(s);
|
|
|
+ };
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ case "end":
|
|
|
+ return _context5.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee5, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function getAllKeys() {
|
|
|
+ return _getAllKeys.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getAllKeys;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "query",
|
|
|
+ value: function () {
|
|
|
+ var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
|
|
|
+ var r, n;
|
|
|
+ return regenerator.wrap(function _callee6$(_context6) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context6.prev = _context6.next) {
|
|
|
+ case 0:
|
|
|
+ r = this.tableName();
|
|
|
+ _context6.next = 3;
|
|
|
+ return this.checkAndOpenDatabase();
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ n = _context6.sent;
|
|
|
+ return _context6.abrupt("return", new Promise(function (o, a) {
|
|
|
+ var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
|
|
|
+ u.onsuccess = function (c) {
|
|
|
+ var f;
|
|
|
+ var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
|
|
|
+ o && o(h);
|
|
|
+ }, u.onerror = function (c) {
|
|
|
+ logger.error("db query error", c), a(c);
|
|
|
+ };
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ case "end":
|
|
|
+ return _context6.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee6, this);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function query(_x4, _x5) {
|
|
|
+ return _query.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return query;
|
|
|
+ }()
|
|
|
+ }, {
|
|
|
+ key: "sleep",
|
|
|
+ value: function () {
|
|
|
+ var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
|
|
|
+ return regenerator.wrap(function _callee7$(_context7) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context7.prev = _context7.next) {
|
|
|
+ case 0:
|
|
|
+ return _context7.abrupt("return", new Promise(function (t) {
|
|
|
+ setTimeout(function () {
|
|
|
+ t("");
|
|
|
+ }, e);
|
|
|
+ }));
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ case "end":
|
|
|
+ return _context7.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee7);
|
|
|
+ }));
|
|
|
+
|
|
|
+ function sleep(_x6) {
|
|
|
+ return _sleep.apply(this, arguments);
|
|
|
+ }
|
|
|
+
|
|
|
+ return sleep;
|
|
|
+ }()
|
|
|
+ }]);
|
|
|
+
|
|
|
+ return BaseTable;
|
|
|
+ }();
|
|
|
+
|
|
|
+ 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 ModelTable = /*#__PURE__*/function (_BaseTable) {
|
|
|
+ _inherits(ModelTable, _BaseTable);
|
|
|
+
|
|
|
+ var _super = _createSuper(ModelTable);
|
|
|
+
|
|
|
+ function ModelTable() {
|
|
|
+ _classCallCheck(this, ModelTable);
|
|
|
+
|
|
|
+ return _super.call(this, "XverseDatabase", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ _createClass(ModelTable, [{
|
|
|
+ key: "tableName",
|
|
|
+ value: function tableName() {
|
|
|
+ return "models";
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "index",
|
|
|
+ value: function index() {
|
|
|
+ return ["url"];
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: "keyPath",
|
|
|
+ value: function keyPath() {
|
|
|
+ return "url";
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ return ModelTable;
|
|
|
+ }(BaseTable);
|
|
|
+
|
|
|
+ var modelTable$1 = new ModelTable();
|
|
|
+
|
|
|
var Preload = /*#__PURE__*/function () {
|
|
|
function Preload(e) {
|
|
|
_classCallCheck(this, Preload);
|
|
@@ -1900,24 +2532,25 @@
|
|
|
case 2:
|
|
|
_context2.prev = 2;
|
|
|
_context2.next = 5;
|
|
|
- return modelTable.getAllKeys();
|
|
|
+ return modelTable$1.getAllKeys();
|
|
|
|
|
|
case 5:
|
|
|
e = _context2.sent;
|
|
|
- return _context2.abrupt("return", (this.allKeys = e, e));
|
|
|
+ this.allKeys = e;
|
|
|
+ return _context2.abrupt("return", e);
|
|
|
|
|
|
- case 9:
|
|
|
- _context2.prev = 9;
|
|
|
+ case 10:
|
|
|
+ _context2.prev = 10;
|
|
|
_context2.t0 = _context2["catch"](2);
|
|
|
t = "preload getAllKeys error";
|
|
|
return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
|
|
|
|
|
|
- case 13:
|
|
|
+ case 14:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}
|
|
|
- }, _callee2, this, [[2, 9]]);
|
|
|
+ }, _callee2, this, [[2, 10]]);
|
|
|
}));
|
|
|
|
|
|
function getAllKeys() {
|
|
@@ -1932,7 +2565,7 @@
|
|
|
e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
|
|
|
var t = this.requests[e].requests;
|
|
|
Object.keys(t).forEach(function (r) {
|
|
|
- http$1.canceler.removePending(r), delete t[r];
|
|
|
+ http.canceler.removePending(r), delete t[r];
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
@@ -2070,7 +2703,7 @@
|
|
|
return !e.includes(n);
|
|
|
});
|
|
|
return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
|
|
|
- return modelTable.delete(n);
|
|
|
+ return modelTable$1.delete(n);
|
|
|
}));
|
|
|
}
|
|
|
}, {
|
|
@@ -2098,7 +2731,7 @@
|
|
|
a = window.setInterval(function () {
|
|
|
r && r(o, n), o >= n && window.clearInterval(a);
|
|
|
}, 1e3);
|
|
|
- return _context6.abrupt("return", mapLimit(t, 10, /*#__PURE__*/function () {
|
|
|
+ return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
|
|
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
|
|
|
var l, u;
|
|
|
return regenerator.wrap(function _callee5$(_context5) {
|
|
@@ -2106,7 +2739,7 @@
|
|
|
switch (_context5.prev = _context5.next) {
|
|
|
case 0:
|
|
|
l = s.size, u = s.url;
|
|
|
- return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http$1.get({
|
|
|
+ return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http.get({
|
|
|
url: u,
|
|
|
timeout: Preload.getTimeoutBySize(l),
|
|
|
responseType: "blob",
|
|
@@ -2138,7 +2771,7 @@
|
|
|
f = _context4.sent;
|
|
|
_context4.prev = 6;
|
|
|
_context4.next = 9;
|
|
|
- return modelTable.put({
|
|
|
+ return modelTable$1.put({
|
|
|
url: u,
|
|
|
model: f
|
|
|
});
|
|
@@ -2388,7 +3021,7 @@
|
|
|
case 0:
|
|
|
_context.prev = 0;
|
|
|
_context.next = 3;
|
|
|
- return (R = xverse.preload) == null ? void 0 : R.start(P, function (M, x) {
|
|
|
+ return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
|
|
|
var I = "(".concat(M, "/").concat(x, ")");
|
|
|
s(I);
|
|
|
});
|
|
@@ -2417,20 +3050,23 @@
|
|
|
_context.prev = 12;
|
|
|
_context.next = 15;
|
|
|
return xverse.joinRoom({
|
|
|
- canvas: f,
|
|
|
- skinId: v,
|
|
|
- avatarId: g,
|
|
|
- roomId: d,
|
|
|
- userId: _,
|
|
|
- wsServerUrl: C,
|
|
|
- appId: m,
|
|
|
+ canvas: document.getElementById('canvas'),
|
|
|
+ skinId: 10092,
|
|
|
+ avatarId: 'KGe_Boy',
|
|
|
+ roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
|
|
|
+ userId: '1f7acca1db9d5',
|
|
|
+ wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
|
|
|
+ appId: 10016,
|
|
|
token: " ",
|
|
|
- nickname: _,
|
|
|
+ nickname: '1f7acca1db9d5',
|
|
|
firends: ["user1"],
|
|
|
viewMode: "full",
|
|
|
- resolution: T,
|
|
|
- pathName: y,
|
|
|
- objectFit: b,
|
|
|
+ resolution: {
|
|
|
+ width: 1728,
|
|
|
+ height: 720
|
|
|
+ },
|
|
|
+ pathName: 'thirdwalk',
|
|
|
+ objectFit: null,
|
|
|
hasAvatar: !0,
|
|
|
syncToOthers: !0
|
|
|
});
|