@honor-minigame/cli
Version:
honor minigame pack cli
15,697 lines • 605 kB
JavaScript
"use strict";
require("@babel/runtime/helpers/Objectvalues"),
require("@babel/runtime/helpers/Arrayincludes"),
require("@babel/runtime/helpers/Objectentries");
var e = require("@babel/runtime/helpers/assertThisInitialized"),
t = require("@babel/runtime/helpers/createForOfIteratorHelper"),
n = require("@babel/runtime/helpers/regeneratorRuntime"),
i = require("@babel/runtime/helpers/construct"),
a = require("@babel/runtime/helpers/inherits"),
r = require("@babel/runtime/helpers/createSuper"),
o = require("@babel/runtime/helpers/typeof"),
s = require("@babel/runtime/helpers/slicedToArray"),
u = require("@babel/runtime/helpers/classCallCheck"),
c = require("@babel/runtime/helpers/createClass"),
l = require("@babel/runtime/helpers/defineProperty");
!(function () {
var h = {
388: function (e, t, n) {
var i, a, r;
n.d(t, {
QD: function () {
return a;
},
C2: function () {
return r;
},
ZP: function () {
return h;
},
Mi: function () {
return f;
},
}),
(function (e) {
(e.STRING = "STRING"),
(e.LONGLONG = "LONGLONG"),
(e.UINT = "UINT"),
(e.INT = "INT");
})(a || (a = {})),
(function (e) {
(e.SvrReport = "SvrReport"), (e.KvStat = "KvStat");
})(r || (r = {}));
var o =
(l((i = {}), a.STRING, function (e) {
return "string" == typeof e && e.length <= 1024;
}),
l(i, a.LONGLONG, function (e) {
return "number" == typeof e && Math.floor(e) === e;
}),
l(i, a.UINT, function (e) {
return "number" == typeof e && Math.floor(e) === e && e >= 0;
}),
l(i, a.INT, function (e) {
return "number" == typeof e && Math.floor(e) === e;
}),
i),
h = (function () {
function e(t) {
var n = t.logid,
i = t.schemas,
a = void 0 === i ? {} : i,
r = t.base,
o = t.debug,
s = void 0 !== o && o,
c = t.namespace,
l = void 0 === c ? "" : c,
h = t.skipValidateInProdEnv,
d = void 0 === h || h;
u(this, e),
(this.debug = !1),
(this.base = {}),
(this.namespace = ""),
(this.skipValidateInProdEnv = !0),
(this.asyncGetBase = function () {
return Promise.resolve({});
}),
(this.logid = n),
(this.schemas = a),
r && this.setBase(r),
(this.debug = s),
(this.skipValidateInProdEnv = d),
(this.namespace = l ? " ".concat(l, " ") : " ");
}
return (
c(e, [
{
key: "setBase",
value: function (e) {
this.validate(e),
(this.base = Object.assign(
Object.assign({}, this.base),
e
));
},
},
{
key: "validate",
value: function (e) {
if (
(this.debug || !this.skipValidateInProdEnv) &&
Object.keys(this.schemas).length
)
for (
var t = 0, n = Object.entries(e);
t < n.length;
t++
) {
var i = s(n[t], 2),
a = i[0],
r = i[1];
if (void 0 !== r) {
var o = this.schemas[a];
o
? this.validateColumn(o, r) ||
console.error(
"[minigamefe"
.concat(
this.namespace,
"SchemaValidator]: logid "
)
.concat(this.logid, ": ")
.concat(a, " should be ")
.concat(o, ", but now ")
.concat(r)
)
: console.warn(
"[minigamefe"
.concat(
this.namespace,
"SchemaValidator]: logid"
)
.concat(this.logid, ": ")
.concat(a, " 缺少类型定义")
);
}
}
},
},
{
key: "validateColumn",
value: function (e, t) {
return o[e](t);
},
},
]),
e
);
})(),
d = "";
function f(e, t, n) {
d
? e && e(d)
: (t({
success: function (t) {
(d = t.networkType), e && e(d);
},
}),
n(function (t) {
(d = t.networkType), t.isConnected || (d = "none"), e && e(d);
}));
}
},
512: function (e, t, n) {
function i() {}
function a() {
for (
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 20,
t = arguments.length > 1 ? arguments[1] : void 0,
n =
(t ? "" : "!#%()*+,-./:;=?@[]^_`{|}~") +
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
i = n.length,
a = [],
r = 0;
r < e;
r++
)
a[r] = n.charAt(Math.random() * i);
return a.join("");
}
function r(e, t) {
if ("string" != typeof e || "string" != typeof t)
return "string" != typeof e && "string" != typeof t
? 0
: "string" != typeof e
? 1
: -1;
for (
var n = e.split("."),
i = t.split("."),
a = Math.max(n.length, i.length);
n.length < a;
)
n.push("0");
for (; i.length < a; ) i.push("0");
for (var r = 0; r < a; r++) {
var o = parseInt(n[r], 10),
s = parseInt(i[r], 10);
if (o > s) return 1;
if (o < s) return -1;
}
return 0;
}
function u(e) {
return "number" == typeof e && isFinite(e);
}
function c(e) {
for (
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: 0,
n =
arguments.length > 2 && void 0 !== arguments[2]
? arguments[2]
: 0,
i = arguments.length,
a = new Array(i > 3 ? i - 3 : 0),
r = 3;
r < i;
r++
)
a[r - 3] = arguments[r];
return new Promise(function (i, r) {
!(function t() {
var o =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0;
e.apply(null, [].concat(a, [o]))
.then(i)
.catch(function (e) {
o > 0
? setTimeout(function () {
t(o - 1);
}, n)
: r(e);
});
})(t);
});
}
function l(e) {
return e
.then(function (e) {
return [null, e];
})
.catch(function (e) {
return [e, null];
});
}
function h(e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: "yyyy-MM-dd";
if (!e) return "";
for (
var n = t,
i =
10 === String(e).toString().length
? new Date(1e3 * e)
: new Date(e),
a = {
"y+": i.getFullYear(),
"M+": i.getMonth() + 1,
"d+": i.getDate(),
"h+": i.getHours(),
"m+": i.getMinutes(),
"s+": i.getSeconds(),
"q+": Math.floor((i.getMonth() + 3) / 3),
"S+": i.getMilliseconds(),
},
r = function () {
var e = s(u[o], 2),
t = e[0],
i = e[1],
a = new RegExp("(".concat(t, ")"));
if (a.test(n)) {
var r = n.match(a),
c = s(r, 1)[0];
n = n.replace(a, function () {
return "00".concat(i).slice(-"".concat(c).length);
});
}
},
o = 0,
u = Object.entries(a);
o < u.length;
o++
)
r();
return n;
}
function d(e) {
if (null == e) return !0;
if ("boolean" == typeof e) return !1;
if ("number" == typeof e) return !e;
if (e instanceof Error) return "" === e.message;
switch (Object.prototype.toString.call(e)) {
case "[object String]":
case "[object Array]":
return !e.length;
case "[object File]":
case "[object Map]":
case "[object Set]":
return !e.size;
case "[object Object]":
return !Object.keys(e).length;
}
return !1;
}
function f(e) {
return "[object String]" === Object.prototype.toString.call(e);
}
function g(e) {
return "[object Object]" === Object.prototype.toString.call(e);
}
function p(e) {
return e && "[object Function]" === Object.prototype.toString.call(e);
}
function m(e) {
return void 0 === e;
}
function v(e) {
var t = e;
try {
"object" == o(e) &&
(t =
"string" == typeof e.errMsg
? e.errMsg
: "string" == typeof e.errmsg
? e.errmsg
: "string" == typeof e.message
? e.message
: JSON.stringify(e));
} catch (e) {
console.error(e);
}
return t;
}
function y(e, t, n) {
if (!n) return e;
var i = e,
a = new RegExp("([?&])".concat(t, "=.*?(&|$)"), "i");
if (i.match(a))
return i.replace(a, "$1".concat(t, "=").concat(n, "$2"));
var r = -1 !== i.indexOf("?") ? "&" : "?",
o = i.split("#");
return (
(i = "".concat(o[0] + r + t, "=").concat(n)),
o[1] && (i += "#".concat(o[1])),
i
);
}
n.d(t, {
YP: function () {
return i;
},
hQ: function () {
return a;
},
yC: function () {
return r;
},
hj: function () {
return u;
},
gj: function () {
return c;
},
zI: function () {
return l;
},
p6: function () {
return h;
},
xb: function () {
return d;
},
HD: function () {
return f;
},
Kn: function () {
return g;
},
mf: function () {
return p;
},
o8: function () {
return m;
},
bV: function () {
return v;
},
vr: function () {
return y;
},
});
},
580: function (e, t, n) {
var i, a, r, o, s;
n.d(t, {
t4: function () {
return i;
},
tE: function () {
return r;
},
dg: function () {
return o;
},
vm: function () {
return s;
},
}),
(function (e) {
(e.devtools = "devtools"),
(e.android = "android"),
(e.ios = "ios"),
(e.windows = "windows"),
(e.mac = "mac");
})(i || (i = {})),
(function (e) {
(e.portrait = "portrait"),
(e.landscape = "landscape"),
(e.landscapeLeft = "landscapeLeft"),
(e.landscapeRight = "landscapeRight");
})(a || (a = {})),
(function (e) {
(e.DEVELOP = "develop"),
(e.TRIAL = "trial"),
(e.RELEASE = "release");
})(r || (r = {})),
(function (e) {
(e[(e.release = 1)] = "release"),
(e[(e.develop = 2)] = "develop"),
(e[(e.trial = 3)] = "trial");
})(o || (o = {})),
(function (e) {
(e[(e.Android = 0)] = "Android"),
(e[(e.IOSJscore = 1)] = "IOSJscore"),
(e[(e.IOSWK = 2)] = "IOSWK"),
(e[(e.UnKnow = 3)] = "UnKnow"),
(e[(e.PC = 4)] = "PC"),
(e[(e.Devtools = 5)] = "Devtools"),
(e[(e.IPadJscore = 6)] = "IPadJscore"),
(e[(e.IPadWK = 7)] = "IPadWK");
})(s || (s = {}));
},
662: function (e, t, n) {
n.d(t, {
Z: function () {
return A;
},
});
var i,
a,
r,
o,
s,
u = n(512),
c = n(974),
l = n(580),
h = !("undefined" == typeof pluginEnv),
d = "undefined" != typeof wx && "undefined" != typeof Page,
f = !("undefined" == typeof wx || d) || h,
g = !1,
p = !1,
m = !1,
v = !1,
y = !1,
S = !1,
T = !1,
b = !1,
w = l.vm.UnKnow,
C = "",
E = "";
if (f || d) {
if (h) {
var k = pluginEnv.customEnv;
k && k.customEnv && (pluginEnv.customEnv = k.customEnv),
(s = "undefined" != typeof wx ? wx : {}),
(a =
pluginEnv.customEnv && pluginEnv.customEnv.wx
? pluginEnv.customEnv.wx
: s);
} else a = wx;
if (a) {
try {
if (
((r = a.getSystemInfoSync() || {}),
(w = (0, c.$)(r)),
r.platform === l.t4.devtools
? (m = !0)
: r.platform === l.t4.ios
? ((g = !0),
(T = !!(null === n.g || void 0 === n.g
? void 0
: n.g.isIOSHighPerformanceMode)))
: r.platform === l.t4.android
? (p = !0)
: r.platform === l.t4.windows
? (y = !0)
: r.platform === l.t4.mac && (S = !0),
(y || S) && (v = !0),
r.model.indexOf("iPad") > -1 && (b = !0),
(0, u.yC)(r.SDKVersion, "2.24.4") >= 0 &&
(null == s ? void 0 : s.getAccountInfoSync))
)
try {
var I = (s.getAccountInfoSync() || {}).plugin,
P = void 0 === I ? {} : I;
(C = P.appId), (E = P.version);
} catch (e) {
console.log(e);
}
} catch (e) {
console.error(e), (r = {});
}
try {
o = a.getAccountInfoSync() || {};
} catch (e) {
console.error(e), (o = {});
}
} else (r = {}), (o = {});
} else (a = {}), (r = {}), (o = {});
var R = {
isMiniGamePlugin: h,
isMiniGame: f,
isMiniProgram: d,
isIOS: g,
isAndroid: p,
isDevtools: m,
isWindows: y,
isMac: S,
isPC: v,
isWK: T,
isIPad: b,
systemInfo: r,
accountInfo: o,
wx: a,
runtimeType: w,
pluginWx: s,
pluginAppId: C,
pluginVersion: E,
};
null === (i = a.onDeviceOrientationChange) ||
void 0 === i ||
i.call(a, function () {
R.systemInfo = a.getSystemInfoSync() || {};
}),
h && (R.pluginEnv = pluginEnv);
var A = R;
},
835: function (e, t, n) {
n.d(t, {
Z: function () {
return h;
},
});
var i = n(512),
s = n(388),
l = n(580),
h = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
var i,
a = e.reportFunc,
r = e.logid,
o = e.schemas,
c = void 0 === o ? {} : o,
l = e.base,
h = e.reportType,
d = e.asyncGetBase,
f =
void 0 === d
? function () {
return Promise.resolve({});
}
: d,
g = e.debug,
p = e.namespace,
m = void 0 === p ? "" : p,
v = e.skipValidateInProdEnv,
y = void 0 === v || v;
return (
u(this, n),
((i = t.call(this, {
logid: r,
schemas: c,
base: l,
debug: g,
namespace: m,
skipValidateInProdEnv: y,
})).reportType = s.C2.SvrReport),
(i.asyncGetBase = f),
a ||
console.error(
"[minigamefe".concat(
i.namespace,
"GameTransferReport]: 未传入上报函数。"
)
),
(i.reportFunc = a),
void 0 !== h && (i.reportType = h),
i
);
}
return (
c(n, [
{
key: "setKvStatBase",
value: function (e, t) {
if (this.reportType === s.C2.KvStat) {
var n = (e.system || "").split(" ");
Object.assign(this.schemas, {
DeviceModel: s.QD.STRING,
DeviceBrand: s.QD.STRING,
OsName: s.QD.STRING,
OsVersion: s.QD.STRING,
LanguageVersion: s.QD.STRING,
Count: s.QD.UINT,
AppId: s.QD.STRING,
AppVersion: s.QD.UINT,
AppState: s.QD.UINT,
}),
this.setBase({
DeviceModel: e.model || "",
DeviceBrand: e.brand || "",
OsName: n[0] || "",
OsVersion: n[1] || "",
LanguageVersion: e.language || "",
Count: 1,
}),
(null == t ? void 0 : t.miniProgram) &&
this.setBase({
AppState:
l.dg[t.miniProgram.envVersion] || l.dg.release,
AppId: t.miniProgram.appId,
AppVersion: 0,
});
}
},
},
{
key: "send",
value: function (e, t) {
var n = this;
if (
this.reportFunc &&
"function" == typeof this.reportFunc
) {
var a,
r = [],
u = this.logid;
(a = Array.isArray(e) ? e : [e]),
this.asyncGetBase().then(function (e) {
n.setBase(e),
a.forEach(function (e) {
var t = Object.assign(
Object.assign({}, n.base),
e
);
if (
(t.ExternInfo &&
"object" == o(t.ExternInfo) &&
n.schemas.ExternInfo === s.QD.STRING &&
(t.ExternInfo = encodeURIComponent(
JSON.stringify(t.ExternInfo)
)),
n.validate(t),
n.reportType === s.C2.KvStat)
) {
var i = Math.floor(Date.now() / 1e3);
Object.assign(t, { StartTime: i, EndTime: i });
}
var a = { log_id: n.logid, custom_data: t };
r.push(a),
n.debug &&
console.log(
"[minigamefe"
.concat(
n.namespace,
"GameTransferReport]: "
)
.concat(u, ","),
t
);
});
var c = { report_list: r };
n.reportFunc({
req_path: "comm_datareport",
json_data: JSON.stringify(c),
success: function () {
t && t(u, JSON.stringify(c));
},
fail: function (e) {
console.error(e), t && t(u, (0, i.bV)(e));
},
});
});
} else
console.error(
"[minigamefe GameTransferReport]: 未传入上报函数!!!"
);
},
},
]),
n
);
})(s.ZP);
},
54: function (e, t, n) {
n.d(t, {
Z: function () {
return s;
},
});
var i = n(388),
o = {
19283: "GameComponent",
19335: "GameWhatsNew",
20285: "MidasFriendPayment",
21494: "WXGameWASMLaunchClose",
21493: "WXGameWASMLaunchException",
21492: "WXGameWASMLaunchTime",
21898: "GameLifeMiniGameCardAction",
20267: "GameAdsSkipCard",
},
s = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
var i,
a = e.reportFunc,
r = e.logid,
s = e.protocolParams,
c = e.schemas,
l = e.base,
h = e.asyncGetBase,
d =
void 0 === h
? function () {
return Promise.resolve({});
}
: h,
f = e.debug,
g = e.namespace,
p = void 0 === g ? "" : g,
m = e.skipValidateInProdEnv,
v = void 0 === m || m;
u(this, n);
var y = r;
return (
"number" == typeof r &&
o[r] &&
((y = o[r]),
f &&
console.warn(
"[minigamefe"
.concat(
p ? " ".concat(p, " ") : " ",
"KeyValueReporter]: logid "
)
.concat(r, " auto map to ")
.concat(y, "!")
)),
((i = t.call(this, {
logid: y,
schemas: c,
base: l,
debug: f,
namespace: p,
skipValidateInProdEnv: v,
})).asyncGetBase = d),
a ||
console.error(
"[minigamefe".concat(
i.namespace,
"KeyValueReporter]: 未传入上报函数。"
)
),
(i.reportFunc = a || function () {}),
(i.protocolParams = s),
(i.sendCbk = null),
i
);
}
return (
c(n, [
{
key: "send",
value: function (e, t) {
var n,
i = this;
(n = Array.isArray(e) ? e : [e]),
this.asyncGetBase().then(function (e) {
i.setBase(e),
n.forEach(function (e) {
var n = Object.assign(Object.assign({}, i.base), e);
i.validate(n);
var a = [];
i.protocolParams.forEach(function (e) {
var t = void 0 !== n[e] ? n[e] : "";
a.push(t);
}),
i.reportFunc({
key: i.logid,
value: a.map(encodeURIComponent).join(","),
immediately: !0,
});
var r = t || i.sendCbk;
r &&
r(i.logid, a.map(encodeURIComponent).join(",")),
i.debug &&
(n.IsError ? console.error : console.log)(
"[minigamefe"
.concat(i.namespace, "keyValueReport]: ")
.concat(i.logid),
n
);
});
});
},
},
]),
n
);
})(i.ZP);
},
865: function (e, t, n) {
n.r(t),
n.d(t, {
default: function () {
return te;
},
});
var i = {};
n.r(i),
n.d(i, {
navigateToMiniProgram: function () {
return h;
},
});
var l = n(662);
function h(e) {
l.Z.wx.navigateToMiniProgram &&
(l.Z.pluginEnv && l.Z.pluginEnv.navigateToMiniProgramDirectly
? l.Z.pluginEnv.navigateToMiniProgramDirectly({ appId: e })
: l.Z.wx.navigateToMiniProgram({ appId: e }));
}
JSON.parse;
var d,
f = JSON.stringify,
g = (Object.keys, String),
p = "object",
m = function (e, t) {
return t;
},
v = function (e, t, n) {
var i = g(t.push(n) - 1);
return e.set(n, i), i;
};
!(function (e) {
(e.log = "log"),
(e.info = "info"),
(e.warn = "warn"),
(e.error = "error");
})(d || (d = {}));
var y,
S,
T,
b,
w = (function () {
function e(t) {
var n = t.reportFunc,
i = t.base,
a = t.debug,
r = t.delimiter,
o = t.namespace;
u(this, e),
(this.reportFunc = null),
(this.debug = !1),
(this.base = {}),
(this.delimiter = " "),
(this.namespace = ""),
n
? ((this.reportFunc = n),
i && this.setBase(i),
(this.debug = !!a),
r && (this.delimiter = r),
(this.namespace = o ? " ".concat(o, " ") : " "))
: console.error("[minigamefe XLog]: 未传入上报函数。");
}
return (
c(e, [
{
key: "setBase",
value: function (e) {
this.base = Object.assign(Object.assign({}, this.base), e);
},
},
{
key: "log",
value: function () {
for (
var e = arguments.length, t = new Array(e), n = 0;
n < e;
n++
)
t[n] = arguments[n];
this.report(d.log, t);
},
},
{
key: "info",
value: function () {
for (
var e = arguments.length, t = new Array(e), n = 0;
n < e;
n++
)
t[n] = arguments[n];
this.report(d.info, t);
},
},
{
key: "warn",
value: function () {
for (
var e = arguments.length, t = new Array(e), n = 0;
n < e;
n++
)
t[n] = arguments[n];
this.report(d.warn, t);
},
},
{
key: "error",
value: function () {
for (
var e = arguments.length, t = new Array(e), n = 0;
n < e;
n++
)
t[n] = arguments[n];
this.report(d.error, t);
},
},
{
key: "getLogStr",
value: function (e, t) {
var n,
i = this;
if (!this.reportFunc)
return (
console.error(
"[minigamefe".concat(
this.namespace,
"XLog]: 未传入上报函数。"
)
),
""
);
if (!t) return "";
var a = "";
t.forEach(function (e) {
a.length > 0 && (a += i.delimiter);
var t = e;
"object" == o(t) &&
(t =
t instanceof TypeError
? t.message
: (function (e, t, n) {
for (
var i =
t && o(t) === p
? function (e, n) {
return "" === e || -1 < t.indexOf(e)
? n
: void 0;
}
: t || m,
a = new Map(),
r = [],
s = [],
u = +v(a, r, i.call({ "": e }, "", e)),
c = !u;
u < r.length;
)
(c = !0), (s[u] = f(r[u++], l, n));
return "[" + s.join(",") + "]";
function l(e, t) {
if (c) return (c = !c), t;
var n = i.call(this, e, t);
switch (o(n)) {
case p:
if (null === n) return n;
case "string":
return a.get(n) || v(a, r, n);
}
return n;
}
})(t)),
(a += "".concat(String(t).trim()));
});
var r = "[minigamefe"
.concat(this.namespace, "XLog]: ")
.concat(
JSON.stringify(
Object.assign(Object.assign({}, this.base), {
type: e,
content: a,
})
)
);
return (
this.debug &&
(null === (n = console[e]) ||
void 0 === n ||
n.call(console, r)),
r
);
},
},
{
key: "report",
value: function (e, t) {
var n = this.reportFunc;
if (n)
if (n[e] && "function" == typeof n[e]) {
var i = this.getLogStr(e, t);
i && n[e](i);
} else
console.error(
"[minigamefe".concat(
this.namespace,
"XLog]: 传入的上报函数格式不对。"
)
);
else
console.error(
"[minigamefe".concat(
this.namespace,
"XLog]: 未传入上报函数。"
)
);
},
},
]),
e
);
})(),
C = n(512);
!(function (e) {
(e[(e.Front = 1)] = "Front"), (e[(e.Background = 2)] = "Background");
})(y || (y = {})),
(function (e) {
(e[(e.Default = 0)] = "Default"),
(e[(e.GameTransfer = 1)] = "GameTransfer"),
(e[(e.Request = 2)] = "Request"),
(e[(e.DownloadFile = 3)] = "DownloadFile"),
(e[(e.CgiSpeedMeasure = 4)] = "CgiSpeedMeasure"),
(e[(e.BadJs = 5)] = "BadJs"),
(e[(e.Init = 6)] = "Init"),
(e[(e.CostTime = 7)] = "CostTime"),
(e[(e.Error = 8)] = "Error"),
(e[(e.UploadFile = 9)] = "UploadFile"),
(e[(e.Login = 10)] = "Login");
})(S || (S = {})),
(function (e) {
(e[(e.Info = 101)] = "Info"),
(e[(e.Warn = 102)] = "Warn"),
(e[(e.Error = 103)] = "Error");
})(T || (T = {})),
(function (e) {
(e.GameTransferReport = "GameTransferReport"),
(e.KeyValueReport = "KeyValueReport"),
(e.WxRequestReport = "WxRequestReport");
})(b || (b = {}));
var E,
k,
I = Object.values(S).filter(function (e) {
return (0, C.hj)(e);
}),
P = new ((function () {
function e() {
u(this, e),
(this.options = {
debug: !1,
logReport: !1,
qualityReportType: b.KeyValueReport,
pluginAppId: "",
pluginVersion: "",
xlogName: "minigamefe",
});
}
return (
c(e, [
{
key: "set",
value: function (e) {
Object.assign(this.options, e);
},
},
{
key: "get",
value: function (e) {
return this.options[e];
},
},
]),
e
);
})())(),
R = (function () {
function e(t) {
u(this, e),
(this.identifier = "".concat(
P.get("pluginAppId") || l.Z.pluginAppId,
"/plugin.js"
)),
(this.quality = t),
this.init();
}
return (
c(e, [
{
key: "init",
value: function () {
var e,
t,
n = this;
null ===
(t =
null === (e = l.Z.wx) || void 0 === e
? void 0
: e.onError) ||
void 0 === t ||
t.call(e, function (e) {
n.processError(e.message);
});
},
},
{
key: "processError",
value: function (e) {
var t;
if (e.indexOf(this.identifier) > -1) {
var n = e.split("\n"),
i = n[0],
a =
null === (t = n[2]) || void 0 === t
? void 0
: t.split(":")[0];
this.quality.innerReport({
Type: S.BadJs,
Target: i,
CostTime: 0,
Result: e,
CustomKey1: a,
});
}
},
},
]),
e
);
})(),
A = n(279);
!(function (e) {
(e.GAMETRANSFER_IS_NOT_EXIST = "gameTransfer is not exist"),
(e.REQUEST_IS_NOT_EXIST = "request is not exist"),
(e.UPLOADFILE_IS_NOT_EXIST = "uploadFile is not exist"),
(e.LOGIN_IS_NOT_EXIST = "login is not exist"),
(e.URL_IS_EMPTY = "request url is empty."),
(e.HEADER_INVALID = "request header is invalid"),
(e.METHOD_IS_NOT_EXIST = "method is not exist");
})(E || (E = {}));
var L = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return c(n);
})(A.TinyEmitter);
!(function (e) {
(e.login = "login"),
(e.gameTransfer = "gameTransfer"),
(e.request = "request"),
(e.uploadFile = "uploadFile"),
(e.downloadFile = "downloadFile");
})(k || (k = {}));
var D = {
QualityReportType: b,
RequestRejectType: E,
ReportType: S,
PluginReportType: T,
},
M = n(835),
x = n(54),
F = "https://game.weixin.qq.com",
_ = "minigamefe_session_id",
O = n(388),
N = n(580),
W = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
var i,
a = e.reportFunc,
r = e.logid,
o = e.schemas,
s = void 0 === o ? {} : o,
c = e.base,
l = e.debug,
h = e.namespace,
d = e.asyncGetBase,
f =
void 0 === d
? function () {
return Promise.resolve({});
}
: d,
g = e.reportType,
p = e.skipValidateInProdEnv,
m = void 0 === p || p;
return (
u(this, n),
((i = t.call(this, {
logid: r,
schemas: s,
base: c,
debug: l,
namespace: h,
skipValidateInProdEnv: m,
})).reportType = O.C2.SvrReport),
(i.reportFunc = a),
a ||
console.error(
"[minigamefe".concat(
i.namespace,
"RequestReport]: 未传入上报函数。"
)
),
(i.asyncGetBase = f),
void 0 !== g && (i.reportType = g),
i
);
}
return (
c(n, [
{
key: "setKvStatBase",
value: function (e, t) {
if (this.reportType === O.C2.KvStat) {
var n = (e.system || "").split(" ");
Object.assign(this.schemas, {
DeviceModel: O.QD.STRING,
DeviceBrand: O.QD.STRING,
OsName: O.QD.STRING,
OsVersion: O.QD.STRING,
LanguageVersion: O.QD.STRING,
Count: O.QD.UINT,
AppId: O.QD.STRING,
AppVersion: O.QD.UINT,
AppState: O.QD.UINT,
}),
this.setBase({
DeviceModel: e.model || "",
DeviceBrand: e.brand || "",
OsName: n[0] || "",
OsVersion: n[1] || "",
LanguageVersion: e.language || "",
Count: 1,
}),
(null == t ? void 0 : t.miniProgram) &&
this.setBase({
AppState:
N.dg[t.miniProgram.envVersion] || N.dg.release,
AppId: t.miniProgram.appId,
AppVersion: 0,
});
}
},
},
{
key: "send",
value: function (e, t) {
var n = this;
if (
this.reportFunc &&
"function" == typeof this.reportFunc
) {
var i,
a = [],
r = this.logid;
(i = Array.isArray(e) ? e : [e]),
this.asyncGetBase().then(function (e) {
var o;
n.setBase(e),
i.forEach(function (e) {
var t = Object.assign(
Object.assign({}, n.base),
e
);
n.validate(t);
var i = { log_id: r, custom_data: t };
a.push(i);
});
var s = JSON.stringify({ report_list: a });
n.debug &&
(o = console).log.apply(
o,
[
"[minigamefe"
.concat(n.namespace, "RequestReport]: ")
.concat(r),
].concat(a)
),
n.reportFunc({
url: "".concat(F, "/cgi-bin/comm/datareport"),
method: "POST",
header: {
"content-type":
"application/x-www-form-urlencoded",
},
data: s,
success: function () {
t && t(r, JSON.stringify(s));
},
fail: function (e) {
console.error(e), t && t(r, (0, C.bV)(e));
},
});
});
} else
console.error(
"[minigamefe RequestReport]: 未传入上报函数!!!"
);
},
},
]),
n
);
})(O.ZP),
U = [
"BenchmarkLevel",
"NetworkType",
"RuntimeType",
"PluginAppId",
"PluginVersion",
"Scene",
"SDKVersion",
"IsVisible",
"Type",
"Target",
"Params",
"Result",
"CostTime",
"ExternInfo",
"CustomKey1",
"CustomKey2",
"CustomKey3",
"IsError",
"FELibVersion",
],
B = {
BenchmarkLevel: O.QD.UINT,
NetworkType: O.QD.STRING,
RuntimeType: O.QD.UINT,
PluginAppId: O.QD.STRING,
PluginVersion: O.QD.STRING,
Scene: O.QD.UINT,
SDKVersion: O.QD.STRING,
IsVisible: O.QD.UINT,
Type: O.QD.UINT,
Target: O.QD.STRING,
Params: O.QD.STRING,
Result: O.QD.STRING,
CostTime: O.QD.UINT,
ExternInfo: O.QD.STRING,
CustomKey1: O.QD.STRING,
CustomKey2: O.QD.STRING,
CustomKey3: O.QD.STRING,
IsError: O.QD.UINT,
FELibVersion: O.QD.STRING,
},
G = n(974),
V = "1.1.47";
function z(e, t) {
var n = e || "";
if ((0, C.Kn)(n))
try {
n = JSON.stringify(n);
} catch (e) {
console.error("[minigamefe stringify error]: ".concat(e)),
(n = "");
}
else n = String(n);
return (
n.length &&
n.length >= 1024 &&
((n = ""),
console.warn(
"[minigamefe stringify warning]: ".concat(
t,
" 上报长度超过1024, 已置空"
)
)),
n
);
}
var j = (function () {
function e(t) {
var n, i;
u(this, e),
(this.benchmarkLevel = 0),
(this.network = ""),
(this.runtimeType = N.vm.UnKnow),
(this.sdkVersion = "0.0.0"),
(this.isVisible = y.Front),
(this.scene = 0),
(this.query = ""),
(this.pluginAppId = ""),
(this.pluginVersion = ""),
(this.inited = !1);
var a = t.systemInfo,
r = t.launchInfo,
o = t.onShow,
s = t.onHide,
c = t.pluginAppId,
l = void 0 === c ? "" : c,
h = t.pluginVersion,
d = void 0 === h ? "" : h;
if (!o || !s)
return (
console.error(
"[minigamefe stringify warning]: please inject QualityConfig correctly"
),
void (this.inited = !1)
);
(this.inited = !0),
(this.onShow = o),
(this.onHide = s),
(this.benchmarkLevel = a.benchmarkLevel + 100),
(this.sdkVersion = a.SDKVersion),
(this.launchInfo = r),
(this.scene =
null === (n = this.launchInfo) || void 0 === n
? void 0
: n.scene),
(this.query = encodeURIComponent(
JSON.stringify(
null === (i = this.launchInfo) || void 0 === i
? void 0
: i.query
)
)),
(this.runtimeType = (0, G.$)(a)),
(this.pluginAppId = l),
(this.pluginVersion = d),
this.bindNativeEvent(),
(this.reporter = (function (e) {
var t,
n = e.type,
i = void 0 === n ? b.KeyValueReport : n,
a = e.reportKeyValue,
r = e.debug,
o = e.gameTransfer,
s = e.systemInfo,
u = e.accountInfo,
c = e.getNetworkType,
l = e.onNetworkStatusChange,
h = e.request,
d = e.namespace,
f = "";
function g() {
return new Promise(function (e) {
f
? e({ NetworkType: f })
: c({
success: function (t) {
(f = t.networkType), e({ NetworkType: f });
},
fail: function () {
e({ NetworkType: (f = "unknown") });
},
});
});
}
return (
i === b.KeyValueReport
? (t = new x.Z({
reportFunc: a,
logid: 26340,
schemas: B,
protocolParams: U,
debug: r,
namespace: d,
asyncGetBase: g,
}))
: i === b.GameTransferReport
? (t = new M.Z({
reportFunc: o,
logid: 26340,
schemas: B,
reportType: O.C2.KvStat,
debug: r,
namespace: d,
asyncGetBase: g,
})).setKvStatBase(s, u)
: (console.warn(
"[minigamefe]: 当前选择 reqeust 进行质量上报, 请自行确保兼容性"
),
(t = new W({
reportFunc: h,
logid: 26340,
schemas: B,
debug: r,
namespace: d,
asyncGetBase: g,
reportType: O.C2.KvStat,
})).setKvStatBase(s, u)),
(i !== b.GameTransferReport && i !== b.WxRequestReport) ||
(0, O.Mi)(
function (e) {
(f = e), t.setBase({ NetworkType: e });
},
c,
l
),
t
);
})(t)),
this.reporter.setBase({
BenchmarkLevel: this.benchmarkLevel,
RuntimeType: this.runtimeType,
Scene: +this.scene,
SDKVersion: this.sdkVersion,
IsVisible: this.isVisible,
PluginAppId: l,
PluginVersion: d,
FELibVersion: V,
});
}
return (
c(e, [
{
key: "bindNativeEvent",
value: function () {
var e = this;
this.onHide(function () {
(e.isVisible = y.Background),
e.reporter.setBase({ IsVisible: e.isVisible });
}),
this.onShow(function () {
e.isVisible = y.Front;
});
},
},
{
key: "innerReport",
value: function (e) {
this.reporter.send(
Object.assign(e, {
CostTime: (0, C.hj)(e.CostTime) ? e.CostTime : 0,
Params: z(e.Params, "Params"),
Result: z(e.Result, "Result"),
ExternInfo: z(e.ExternInfo, "ExternInfo"),
})
);
},
},
{
key: "report",
value: function (e) {
I.indexOf(e.Type) > -1 &&
console.error(
"[minigamefe quality report]: 若为自定义上报, Type 请不要使用内置枚举值 ".concat(
e.Type,
", 内置枚举可见 mgp.consts.ReportType"
)
),
this.inited && this.innerReport(e);
},
},
{
key: "setCustomKey",
value: function (e) {
this.inited &&
this.reporter.setBase({
CustomKey1:
(e.CustomKey1 && z(e.CustomKey1, "CustomKey1")) || "",
CustomKey2:
(e.CustomKey2 && z(e.CustomKey2, "CustomKey2")) || "",
CustomKey3:
(e.CustomKey3 && z(e.CustomKey3, "CustomKey3")) || "",
});
},
},
{
key: "clearCustomKey",
value: function () {
this.inited &&
this.reporter.setBase({
CustomKey1: "",
CustomKey2: "",
CustomKey3: "",
});
},
},
]),
e
);
})(),
H = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
var i;
return (
u(this, n),
((i = t.call(this)).startTime = 0),
(i.costTime = 0),
(i.isSupportNoStringifyReqData = !1),
(i.options = e),
(i.isSupportNoStringifyReqData = !!(
(0, C.yC)(l.Z.systemInfo.SDKVersion, "2.29.1") >= 0
)),
i
);
}
return (
c(n, [
{
key: "optionsFilter",
value: function (e) {
return (
e.sessionId &&
e.data &&
!e.data.session_id &&
(e.data.session_id = e.sessionId),
(e.timeout = e.timeout || 3e4),
e
);
},
},
{
key: "send",
value: function () {
var e = this;
this.startTime = Date.now();
var t = this.options,
n = t.url,
i = t.data,
a = t.flat,
r = void 0 !== a && a,
o = t.timeout,
s = i || {},
u = s && (0, C.Kn)(s);
u &&
(s["requestTime_".concat((0, C.hQ)(10, !0))] =
Date.now());
var c = {
req_path: n,
timeout: o,
success: function (t) {
(e.costTime = Date.now() - e.startTime),
(e.sourceResponse = t),
(e.response = (function (e) {
var t = e.rawData,
n = void 0 === t ? "" : t,
i = e.respData,
a = n || (void 0 === i ? {} : i).data || "";
if (!a) return {};
try {
return JSON.parse(a);
} catch (e) {
return {};
}
})(t)),
e.emit("success"),
e.emit("complete", 0);
},
fail: function (t) {
(e.costTime = Date.now() - e.startTime),
e.emit("error", t),
e.emit("complete", 1);
},
};
if (!r) {
var h = u ? JSON.stringify(s) : s;
this.isSupportNoStringifyReqData
? ((c.reqData = { req_path: n, json_data: h }),
delete c.req_path)
: (c.json_data = h);
}
r &&
u &&
(this.isSupportNoStringifyReqData
? ((c.reqData = Object.assign({ req_path: n }, s)),
delete c.req_path)
: (c = Object.assign(Object.assign({}, s), c))),
l.Z.pluginEnv.gameTransfer(c);
},
},
]),
n
);
})(L),
q = (function () {
function e(t) {
u(this, e),
(this.sessionId = ""),
(this.login = t.login),
(this.request = t.request);
}
return (
c(e, [
{
key: "getSessionId",
value: function (e) {
var t = this;
return this.checkSession().catch(function () {
return t.loginWxGame(e);
});
},
},
{
key: "clearSessionId",
value: function () {
var e, t;
(this.sessionId = ""),
null === (t = (e = l.Z.wx).removeStorageSync) ||
void 0 === t ||
t.call(e, _);
},
},
{
key: "checkSession",
value: function () {
var e = this;
return new Promise(function (t, n) {
var i,
a,
r,
o,
s =
e.sessionId ||
(null === (a = (i = l.Z.wx).getStorageSync) ||
void 0 === a
? void 0
: a.call(i, _));
s
? null === (o = (r = l.Z.wx).checkSession) ||
void 0 === o ||
o.call(r, {
success: function () {
t({ sessionId: s });
},
fail: function (t) {
e.clearSessionId(), n(t);
},
})
: n({ errMsg: "尚未保存sessionId" });
});
},
},
{
key: "loginWxGame",
value: function (e) {
var t = this;
return (
this.isLoginPromise ||
(this.isLoginPromise = new Promise(function (n, i) {
t.login({})
.then(function (n) {
var i = { code: s(n, 1)[0].code };
return (
e && (i.appid = e),
t.request({
url: "".concat(
F,
"/cgi-bin/gameweappauthwap/login"
),
data: i,
method: "POST",
})
);
})
.then(function (e) {
var a,
r,
o = s(e, 1)[0];
o && o.data
? (l.Z.isMiniGamePlugin ||
null ===
(r = (a = l.Z.wx).setStorageSync) ||
void 0 === r ||
r.call(a, _, o.data.session_id),
(t.sessionId = o.data.session_id || ""),
n({ sessionId: o.data.session_id }))
: i({ errMsg: "登录出错" });
})
.catch(function () {
i({ errMsg: "登录出错" });
});
})),
this.isLoginPromise.finally(function () {
t.isLoginPromise = void 0;
})
);
},
},
]),
e
);
})();
function Q(e, t) {
var n, i;
if (!e) return "";
var a = e,
r = t;
return (
r ||
(r =
null === (i = (n = l.Z.wx).getStorageSync) || void 0 === i
? void 0
: i.call(n, _)),
r && (a = (0, C.vr)(a, "session_id", r)),
a
);
}
var K = (function (e) {
a(n, e);
var t = r(n);
function n(e, i) {
var a;
return (
u(this, n),
((a = t.call(this)).startTime = 0),
(a.costTime = 0),
(a.resAsResponse = !1),
(a.options = e),
(a.requestFunc = i),
a
);
}
return (
c(n, [
{
key: "optionsFilter",
value: function (e) {
return e.sessionId && (e.url = Q(e.url, e.sessionId)), e;
},
},
{
key: "send",
value: function () {
var e = this;
this.startTime = Date.now();
var t = this.options,
n = Object.assign(t, {
success: function (t) {
(e.sourceResponse = t),
(e.costTime = Date.now() - e.startTime);
var n = (e.resAsResponse ? t : t.data) || {};
if ((0, C.HD)(n))
try {
n = JSON.parse(n);
} catch (t) {
n = {};
}
(e.response = n),
e.emit("success"),
e.emit("complete", 0);
},
fail: function (t) {
(e.costTime = Date.now() - e.startTime),
e.emit("error", t),
e.emit("complete", 1);
},
});
this.requestFunc(n);
},
},
]),
n
);
})(L),
X = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
return (
u(this, n),
t.call(
this,
e,
l.Z.isMiniGamePlugin ? l.Z.pluginWx.request : l.Z.wx.request
)
);
}
return (
c(n, [
{
key: "optionsFilter",
value: function (e) {
return (
(e.timeout = e.timeout || 3e4),
e.header &&
(e.header = Object.assign(
{ "content-type": "application/json; charset=utf-8" },
e.header || {}
)),
(e.method = e.method ? e.method.toUpperCase() : "GET"),
e.sessionId && (e.url = Q(e.url, e.sessionId)),
e
);
},
},
]),
n
);
})(K),
Z = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
return (
u(this, n),
t.call(
this,
e,
l.Z.isMiniGamePlugin
? l.Z.pluginWx.uploadFile
: l.Z.wx.uploadFile
)
);
}
return c(n);
})(K),
J = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.call(
this,
{},
l.Z.isMiniGamePlugin ? l.Z.pluginWx.login : l.Z.wx.login
)).resAsResponse = !0),
e
);
}
return c(n);
})(K),
Y = (function (e) {
a(n, e);
var t = r(n);
function n(e) {
var i;
return (
u(this, n),
((i = t.call(
this,
e,
l.Z.isMiniGamePlugin
? l.Z.pluginWx.downloadFile
: l.Z.wx.downloadFile
)).resAsResponse = !0),
i
);
}
return c(n);
})(K),
$ = (function () {
function e(t) {
var n = t.pluginAppId,
i = void 0 === n ? "" : n,
a = t.debug,
r = void 0 !== a && a,
o = t.quality,
s = t.namespace;
u(this, e),
(this.login = this.initWxMethod({
funcName: k.login,
Constructor: J,
reportType: S.Login,
})),
(this.request = this.initWxMethod({
funcName: k.request,
Constructor: X,
reportType: S.Request,
})),
(this.uploadFile = this.initWxMethod({
funcName: k.uploadFile,
Constructor: Z,
reportType: S.UploadFile,
})),
(this.downloadFile = this.initWxMethod({
funcName: k.downloadFile,
Constructor: Y,
reportType: S.DownloadFile,
})),
(this.namespace = ""),
(this.errCodeIgnoreList = []),
(this.debug = r),
(this.pluginAppId = i),
(this.quality = o),
(this.namespace = s ? " ".concat(s, " ") : " "),
(this.session = new q({
login: this.login,
request: this.request,
})),
l.Z.isMiniGamePlugin &&
(this.gameTransfer = this.initGameTransfer());
}
return (
c(e, [
{
key: "initGameTransfer",
value: function () {
var e = this;
if (l.Z.pluginEnv.gameTransfer) {
var t = {
Constructor: H,
funcName: k.gameTransfer,
reportType: S.GameTransfer,
};
return this.initMethodNeedSession(function (n) {
return e.innerRequest(n, t);
});
}
return (
console.warn(
"[minigamfe".concat(
this.namespace,
"]: 当前插件不支持 gameTransfer。"
)
),
function () {
return new Promise(function (e, t) {
t(E.GAMETRANSFER_IS_NOT_EXIST);
});
}
);
},
},
{
key: "initWxMethod",
value: function (e) {
var t = this,
n = e.funcName,
i = e.Constructor,
a = e.reportType,
r = l.Z.isMiniGamePlugin ? l.Z.pluginWx : l.Z.wx;
if (void 0 !== r && r[n]) {
var o = { Constructor: i, funcName: n, reportType: a },
s = function (e) {
return t.innerRequest(e || {}, o);
};
return n === k.request || n === k.uploadFile
? this.initMethodNeedSession(s)
: s;
}
return (
console.warn(
"[minigamfe"
.concat(this.namespace, "]: 当前环境不支持 ")
.concat(n, "。")
),
function () {
return new Promise(function (e, t) {
t(E.METHOD_IS_NOT_EXIST);
});
}
);
},
},
{
key: "initMethodNeedSession",
value: function (e) {
var t = this;
return function (n) {
return n.needSession
? t.session
.getSessionId(t.pluginAppId)
.then(function (t) {
return e(Object.assign(n, t));
})
.then(function (i) {
var a,
r = s(i, 2),
o = r[0],
u = r[1];
return 401 ===
(null == u ? void 0 : u.statusCode) ||
"-1702220400" == "".concat((a = o.errcode)) ||
"-1702220401" == "".concat(a) ||
"-1702220407" == "".concat(a) ||
"-1702220402" == "".concat(a) ||
"40001" == "".concat(a)
? (t.session.clearSessionId(),
t.session
.getSessionId(t.pluginAppId)
.then(function (t) {
return e(Object.assign(n, t));
}))
: [o, u];
})
: e(n);
};
},
},
{
key: "innerRequest",
value: function (e, t) {
var n = this;
return new Promise(function (i, a) {
var r = t.Constructor,
o = t.funcName,
s = t.reportType;
if (o === k.login || e.url) {
var u = new r(e);
u.optionsFilter(e),
u.on("success", function () {
var t;
n.debug &&
!0 !== e.silent &&
console.log(
"[minigamefe"
.concat(n.namespace, "Network]: ")
.concat(o, " end with success"),
u.response
);
var a = u.response,
r = u.sourceResponse,
c = u.costTime,
l = a.errcode,
h = a.errmsg;
e.reduceErrmsgBeforeReport &&
(0, C.mf)(e.reduceErrmsgBeforeReport) &&
(h = e.reduceErrmsgBeforeReport(a)),
o !== k.login ||
a.code ||
((h = a.errMsg), (l = 9999)),
(0, C.hj)(l) &&
0 !== Number(l) &&
!0 !== e.silent &&
-1 === n.errCodeIgnoreList.indexOf(Number(l)) &&
(null === (t = n.quality) ||
void 0 === t ||
t.innerReport({
Type: s,
Target: e.url || "",
Params: e.data,
CostTime: c,
Result: { errcode: l, errmsg: h },
IsError: 1,
})),
i([a, r]);
}),
u.on("error", function (t) {
var i;
!0 !== e.silent &&
(n.debug &&
console.error(
"[minigamefe"
.concat(n.namespace, "Network]: ")
.concat(o, " end with error"),
e,
t
),
null === (i = n.quality) ||
void 0 === i ||
i.innerReport({
Type: s,
Target: e.url || "",
CostTime: u.costTime,
Params: e.data,
Result: (0, C.bV)(t),
IsError: 1,
})),
a(t);
}),
u.on("complete", function () {
var t,
i =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0;
!0 !== e.silent &&
Math.random() < 0.1 &&
(null === (t = n.quality) ||
void 0 === t ||
t.innerReport({
Type: S.CgiSpeedMeasure,
Target: e.url || "",
Params: e.data,
CostTime: u.costTime,
IsError: i,
}));
}),
n.debug &&
!0 !== e.silent &&
console.log(
"[minigamefe"
.concat(n.namespace, "Network]: ")
.concat(o, " start"),
e
),
u.send();
} else a(E.URL_IS_EMPTY);
});
},
},
{
key: "addIgnoreErrCode",
value: function (e) {
var t = this;
(Array.isArray(e) ? e : [e]).forEach(function (e) {
-1 === t.errCodeIgnoreList.indexOf(e) &&
t.errCodeIgnoreList.push(e);
});
},
},
{
key: "removeIgnoreErrCode",
value: function (e) {
var t = this;
(Array.isArray(e) ? e : [e]).forEach(function (e) {
t.errCodeIgnoreList.indexOf(e) > -1 &&
t.errCodeIgnoreList.splice(
t.errCodeIgnoreList.indexOf(e),
1
);
});
},
},
{
key: "setRequestQualityReporter",
value: function (e) {
this.quality = e;
},
},
]),
e
);
})(),
ee = Date.now(),
te = new ((function () {
function e() {
u(this, e),
(this.version = V),
(this.consts = D),
(this.env = l.Z),
(this.util = i),
(this.config = P),
(this.reporter = {
GameTransferReport: M.Z,
KeyValueReporter: x.Z,
});
}
return (
c(e, [
{
key: "init",
value: function (e) {
var t;
if (
(console.log("[minigamefe mgp]: inited"),
(n.g.mgp = this),
this.config.set(e),
(this.network = new $({
pluginAppId:
this.config.get("pluginAppId") ||
l.Z.pluginAppId ||
"",
debug: this.config.get("debug") || !1,
namespace: "mgp",
})),
l.Z.isMiniGamePlugin)
) {
var i = l.Z.pluginEnv;
i.gameTransfer || i.reportKeyValue
? ((this.quality = new j({
debug:
this.config.get("debug") &&
this.config.get("logReport"),
type: this.config.get("qualityReportType"),
pluginAppId:
this.config.get("pluginAppId") ||
l.Z.pluginAppId ||
"",
pluginVersion:
this.config.get("pluginVersion") ||
l.Z.pluginVersion ||
"",
launchInfo: l.Z.wx.getLaunchOptionsSync(),
accountInfo: l.Z.accountInfo,
systemInfo: l.Z.systemInfo,
onShow: l.Z.wx.onShow,
onHide: l.Z.wx.onHide,
getNetworkType: l.Z.wx.getNetworkType,
onNetworkStatusChange: l.Z.wx.onNetworkStatusChange,
gameTransfer:
null === l.Z || void 0 === l.Z
? void 0
: l.Z.pluginEnv.gameTransfer,
reportKeyValue:
null ===
(t =
null === l.Z || void 0 === l.Z
? void 0
: l.Z.pluginEnv) || void 0 === t
? void 0
: t.reportKeyValue,
request: l.Z.pluginWx.request,
namespace: "mgp",
})),
this.network.setRequestQualityReporter(this.quality),
this.quality.innerReport({
Type: S.Default,
Target: "init",
CostTime: Date.now() - ee,
}),
new R(this.quality))
: (console.warn(
"[minigamefe mgp]: 当前环境不支持质量上报。"
),
(this.quality = { report: C.YP }));
var a = this.config.get("debug");
i.getXLogManager
? ((this.xlog = new w({
reportFunc: i.getXLogManager(),
namespace: "mgp",
base: { name: this.config.get("xlogName") },
debug: a,
})),
a &&
console.info(
"[minigamefe mgp]: 当前插件已支持 xlog, 建议在关键操作打客户端日志。"
))
: ((this.xlog = console),
a &&
console.info(
"[minigamefe MGP]: 当前客户端不支持 xlog, 降级为 console。"
));
} else
console.warn(
"[minigamefe mgp]: please use mgp in minigame plugin"
);
},
},
]),
e
);
})())();
},
974: function (e, t, n) {
n.d(t, {
$: function () {
return a;
},
});
var i = n(580);
function a(e) {
var t,
a,
r = i.vm.UnKnow;
return (
e.platform === i.t4.devtools
? (r = i.vm.Devtools)
: e.platform === i.t4.ios
? ((r = (
null === (t = n.g) || void 0 === t
? void 0
: t.isIOSHighPerformanceMode
)
? i.vm.IOSWK
: i.vm.IOSJscore),
e.model.indexOf("iPad") > -1 &&
(r = (
null === (a = n.g) || void 0 === a
? void 0
: a.isIOSHighPerformanceMode
)
? i.vm.IPadWK
: i.vm.IPadJscore))
: e.platform === i.t4.android
? (r = i.vm.Android)
: e.platform === i.t4.windows && (r = i.vm.PC),
r
);
}
},
729: function (e) {
var t = Object.prototype.hasOwnProperty,
n = "~";
function i() {}
function a(e, t, n) {
(this.fn = e), (this.context = t), (this.once = n || !1);
}
function r(e, t, i, r, o) {
if ("function" != typeof i)
throw new TypeError("The listener must be a function");
var s = new a(i, r || e, o),
u = n ? n + t : t;
return (
e._events[u]
? e._events[u].fn
? (e._events[u] = [e._events[u], s])
: e._events[u].push(s)
: ((e._events[u] = s), e._eventsCount++),
e
);
}
function o(e, t) {
0 == --e._eventsCount ? (e._events = new i()) : delete e._events[t];
}
function s() {
(this._events = new i()), (this._eventsCount = 0);
}
Object.create &&
((i.prototype = Object.create(null)), new i().__proto__ || (n = !1)),
(s.prototype.eventNames = function () {
var e,
i,
a = [];
if (0 === this._eventsCount) return a;
for (i in (e = this._events))
t.call(e, i) && a.push(n ? i.slice(1) : i);
return Object.getOwnPropertySymbols
? a.concat(Object.getOwnPropertySymbols(e))
: a;
}),
(s.prototype.listeners = function (e) {
var t = n ? n + e : e,
i = this._events[t];
if (!i) return [];
if (i.fn) return [i.fn];
for (var a = 0, r = i.length, o = new Array(r); a < r; a++)
o[a] = i[a].fn;
return o;
}),
(s.prototype.listenerCount = function (e) {
var t = n ? n + e : e,
i = this._events[t];
return i ? (i.fn ? 1 : i.length) : 0;
}),
(s.prototype.emit = function (e, t, i, a, r, o) {
var s = n ? n + e : e;
if (!this._events[s]) return !1;
var u,
c,
l = this._events[s],
h = arguments.length;
if (l.fn) {
switch ((l.once && this.removeListener(e, l.fn, void 0, !0), h)) {
case 1:
return l.fn.call(l.context), !0;
case 2:
return l.fn.call(l.context, t), !0;
case 3:
return l.fn.call(l.context, t, i), !0;
case 4:
return l.fn.call(l.context, t, i, a), !0;
case 5:
return l.fn.call(l.context, t, i, a, r), !0;
case 6:
return l.fn.call(l.context, t, i, a, r, o), !0;
}
for (c = 1, u = new Array(h - 1); c < h; c++)
u[c - 1] = arguments[c];
l.fn.apply(l.context, u);
} else {
var d,
f = l.length;
for (c = 0; c < f; c++)
switch (
(l[c].once && this.removeListener(e, l[c].fn, void 0, !0), h)
) {
case 1:
l[c].fn.call(l[c].context);
break;
case 2:
l[c].fn.call(l[c].context, t);
break;
case 3:
l[c].fn.call(l[c].context, t, i);
break;
case 4:
l[c].fn.call(l[c].context, t, i, a);
break;
default:
if (!u)
for (d = 1, u = new Array(h - 1); d < h; d++)
u[d - 1] = arguments[d];
l[c].fn.apply(l[c].context, u);
}
}
return !0;
}),
(s.prototype.on = function (e, t, n) {
return r(this, e, t, n, !1);
}),
(s.prototype.once = function (e, t, n) {
return r(this, e, t, n, !0);
}),
(s.prototype.removeListener = function (e, t, i, a) {
var r = n ? n + e : e;
if (!this._events[r]) return this;
if (!t) return o(this, r), this;
var s = this._events[r];
if (s.fn)
s.fn !== t ||
(a && !s.once) ||
(i && s.context !== i) ||
o(this, r);
else {
for (var u = 0, c = [], l = s.length; u < l; u++)
(s[u].fn !== t ||
(a && !s[u].once) ||
(i && s[u].context !== i)) &&
c.push(s[u]);
c.length
? (this._events[r] = 1 === c.length ? c[0] : c)
: o(this, r);
}
return this;
}),
(s.prototype.removeAllListeners = function (e) {
var t;
return (
e
? ((t = n ? n + e : e), this._events[t] && o(this, t))
: ((this._events = new i()), (this._eventsCount = 0)),
this
);
}),
(s.prototype.off = s.prototype.removeListener),
(s.prototype.addListener = s.prototype.on),
(s.prefixed = n),
(s.EventEmitter = s),
(e.exports = s);
},
279: function (e) {
function t() {}
(t.prototype = {
on: function (e, t, n) {
var i = this.e || (this.e = {});
return (i[e] || (i[e] = [])).push({ fn: t, ctx: n }), this;
},
once: function (e, t, n) {
var i = this;
function a() {
i.off(e, a), t.apply(n, arguments);
}
return (a._ = t), this.on(e, a, n);
},
emit: function (e) {
for (
var t = [].slice.call(arguments, 1),
n = ((this.e || (this.e = {}))[e] || []).slice(),
i = 0,
a = n.length;
i < a;
i++
)
n[i].fn.apply(n[i].ctx, t);
return this;
},
off: function (e, t) {
var n = this.e || (this.e = {}),
i = n[e],
a = [];
if (i && t)
for (var r = 0, o = i.length; r < o; r++)
i[r].fn !== t && i[r].fn._ !== t && a.push(i[r]);
return a.length ? (n[e] = a) : delete n[e], this;
},
}),
(e.exports = t),
(e.exports.TinyEmitter = t);
},
},
d = {};
function f(e) {
var t = d[e];
if (void 0 !== t) return t.exports;
var n = (d[e] = { exports: {} });
return h[e](n, n.exports, f), n.exports;
}
(f.n = function (e) {
var t =
e && e.__esModule
? function () {
return e.default;
}
: function () {
return e;
};
return f.d(t, { a: t }), t;
}),
(f.d = function (e, t) {
for (var n in t)
f.o(t, n) &&
!f.o(e, n) &&
Object.defineProperty(e, n, { enumerable: !0, get: t[n] });
}),
(f.g = (function () {
if (
"object" ==
("undefined" == typeof globalThis ? "undefined" : o(globalThis))
)
return globalThis;
try {
return this || new Function("return this")();
} catch (e) {
if (
"object" == ("undefined" == typeof window ? "undefined" : o(window))
)
return window;
}
})()),
(f.o = function (e, t) {
return Object.prototype.hasOwnProperty.call(e, t);
}),
(f.r = function (e) {
"undefined" != typeof Symbol &&
Symbol.toStringTag &&
Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }),
Object.defineProperty(e, "__esModule", { value: !0 });
});
var g = {};
(function () {
var o;
f.r(g),
f.d(g, {
default: function () {
return ca;
},
});
var h,
d,
p,
m,
v,
y,
S,
T,
b,
w,
C,
E,
k,
I,
P,
R = f(865).default,
A = R.env,
L = "1.2.32";
if (
(R.init({
debug: !1,
pluginAppId: "wxe5a48f1ed5f544b7",
pluginVersion: L,
xlogName: "unityPlugin",
}),
A.isMiniGamePlugin)
) {
var D,
M = A.pluginEnv,
x = M.customEnv;
(h = A.wx),
(d = x.unityNamespace),
(p = x.canvas),
x.document,
(m =
M.reportKeyValue ||
function () {
console.warn("当前环境没有reportKeyValue函数!!");
}),
(v =
M.gameTransfer ||
function () {
console.warn("当前环境没有gameTransfer函数");
}),
(k = M.instanceId || ""),
(E = M.setFileSpaceStatistics),
(I = M.getPrivateFileSystemManager),
(y = M.coverview),
(P = M.getWxCommonFont),
y
? ((S = (D = y).Component),
(T = D.getPrivateThis),
D.removePrivateThis,
D.create,
(b = D.init),
(w = D.webviewLayout),
(C = D.xmlParser))
: (S = c(function e() {
u(this, e);
}));
} else
(h = wx),
(d = GameGlobal.unityNamespace),
(p = GameGlobal.canvas),
GameGlobal.document,
(m = function () {}),
(v = function () {}),
(S = function () {}),
(T = function (e) {
return e;
}),
(k = "");
d.isCacheableFile =
d.isCacheableFile ||
function (e) {
return e.includes("StreamingAssets");
};
var F,
_ = f(512),
O = f(580),
N = A.systemInfo,
W = A.accountInfo,
U = N.pixelRatio,
B = (N.platform, N.benchmarkLevel),
G = N.screenHeight,
V = N.screenWidth,
z = N.enableDebug,
j = N.SDKVersion,
H = N.version,
q = (W || {}).miniProgram,
Q = h.getFileSystemManager(),
K = q.envVersion,
X = K === O.tE.RELEASE,
Z = K === O.tE.DEVELOP,
J = A.isWK && (0, _.yC)(j, "2.19.1") >= 0,
Y = z,
$ = !!d.enableDebugLog,
ee = !!Y || !!A.isDevtools,
te = (0, _.yC)(j, "2.21.2") >= 0,
ne = !!y,
ie = A.isAndroid && 0 === (0, _.yC)(H, "8.0.25"),
ae = !!h.reportScene && (0, _.yC)(H, "8.0.27") > -1,
re = !!d.instantiateWasm,
oe =
(A.isAndroid && (0, _.yC)(H, "8.0.34") > -1) ||
(A.isIOS && (0, _.yC)(H, "8.0.39") > -1),
se = h.getLogManager({ level: 1 }),
ue = h.getRealtimeLogManager
? h.getRealtimeLogManager()
: {
info: function () {
console.warn("当前环境不支持实时日志");
},
error: function () {
console.warn("当前环境不支持实时日志");
},
},
ce = (function () {
function e() {
u(this, e);
}
return (
c(e, null, [
{
key: "getInstance",
value: function () {
return (
this.instance || (this.instance = new this()), this.instance
);
},
},
]),
e
);
})();
!(function (e) {
(e.Fps = "fps"),
(e.EnableMonitor = "enableMonitor"),
(e.MonitorDuration = "monitorDuration"),
(e.ShowResultAfterLaunch = "showResultAfterLaunch"),
(e.ShowSuggestModal = "showSuggestModal"),
(e.ShowReportModal = "SHOW_REPORT_MODAL");
})(F || (F = {}));
var le,
he,
de,
fe = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.call(this)).config = {
fps: 10,
monitorDuration: 3e4,
showResultAfterLaunch: !0,
showSuggestModal: !0,
}),
e.init(),
e
);
}
return (
c(n, [
{
key: "getConfig",
value: function (e) {
return this.config[e];
},
},
{
key: "setConfig",
value: function (e, t) {
this.config[e] = t;
},
},
{
key: "init",
value: function () {
try {
var e = d.monitorConfig,
t = void 0 === e ? {} : e,
n = JSON.parse(JSON.stringify(t)),
i = !!n.INJECT_CONIFG && !!n.FORCE_ENABLE;
(n.enableMonitor = (!X && !!n.enableMonitor) || i),
(this.config = Object.assign(
Object.assign({}, this.config),
n
)),
(this.config.SHOW_REPORT_MODAL = !!n.SHOW_REPORT_MODAL);
} catch (e) {
this.config.enableMonitor = !1;
}
},
},
]),
n
);
})(ce).getInstance(),
ge = h.env.USER_DATA_PATH,
pe = "__GAME_FILE_CACHE",
me = "".concat(ge, "/__GAME_FILE_CACHE"),
ve = "wxfile://__wxprivate__",
ye = 1024,
Se = ((A.isPC ? 2048 : d.maxStorage || 200) - 5) * ye * ye;
!(function (e) {
(e[(e.LONG_VIDEO = 0)] = "LONG_VIDEO"),
(e[(e.INTERACTIVE_VIDEO = 1)] = "INTERACTIVE_VIDEO"),
(e[(e.COVER_VIEW = 2)] = "COVER_VIEW");
})(le || (le = {})),
(function (e) {
(e[(e.NEED_NOT_DOWNLOAD = 0)] = "NEED_NOT_DOWNLOAD"),
(e[(e.NEED_DOWNLOAD = 1)] = "NEED_DOWNLOAD");
})(he || (he = {})),
(function (e) {
(e[(e.AllCached = 0)] = "AllCached"),
(e[(e.DownloadAll = 1)] = "DownloadAll"),
(e[(e.DownloadDataPackage = 2)] = "DownloadDataPackage"),
(e[(e.DownloadWasmCode = 3)] = "DownloadWasmCode");
})(de || (de = {}));
var Te,
be,
we,
Ce,
Ee,
ke,
Ie,
Pe,
Re,
Ae = {
0: "资源有缓存",
1: "资源无缓存",
2: "仅下载首资源包",
3: "仅下载wasm包",
};
!(function (e) {
(e[(e.GAME_LAUNCH = 0)] = "GAME_LAUNCH"),
(e[(e.LOAD_SUBPACKAGE = 1)] = "LOAD_SUBPACKAGE"),
(e[(e.COMPILE_WASM = 2)] = "COMPILE_WASM"),
(e[(e.LOAD_ASSETS = 3)] = "LOAD_ASSETS"),
(e[(e.UNZIP_ASSETS = 4)] = "UNZIP_ASSETS"),
(e[(e.READ_ASSETS = 5)] = "READ_ASSETS"),
(e[(e.PREPARE_GAME = 6)] = "PREPARE_GAME"),
(e[(e.GAME_START = 7)] = "GAME_START"),
(e[(e.LOAD_ASSET_BUNDLE = 8)] = "LOAD_ASSET_BUNDLE"),
(e[(e.FILE_SYSTEM_INIT = 9)] = "FILE_SYSTEM_INIT"),
(e[(e.GET_CONTEXT = 10)] = "GET_CONTEXT"),
(e[(e.LOAD_BACKGROUND_IMAGE = 11)] = "LOAD_BACKGROUND_IMAGE"),
(e[(e.COVER_VIEW_INIT = 12)] = "COVER_VIEW_INIT");
})(Te || (Te = {})),
(function (e) {
(e[(e.DEFAULT = 50)] = "DEFAULT"),
(e[(e.UNZIP = 51)] = "UNZIP"),
(e[(e.WRITEFILE = 52)] = "WRITEFILE"),
(e[(e.RELEASE_ERROR = 53)] = "RELEASE_ERROR"),
(e[(e.DELETE_FILE = 54)] = "DELETE_FILE"),
(e[(e.EXCEED_MAX = 55)] = "EXCEED_MAX"),
(e[(e.QUOTA_CONTROL = 56)] = "QUOTA_CONTROL"),
(e[(e.STAT_SIZE_EXCEED = 57)] = "STAT_SIZE_EXCEED"),
(e[(e.STAT_SIZE_NORMAL = 58)] = "STAT_SIZE_NORMAL"),
(e[(e.OUT_OF_RANGE = 59)] = "OUT_OF_RANGE");
})(be || (be = {})),
(function (e) {
e[(e.FONT = 80)] = "FONT";
})(we || (we = {})),
(function (e) {
(e[(e.BASE_INFO = 70)] = "BASE_INFO"),
(e[(e.ASSETS_INFO = 71)] = "ASSETS_INFO"),
(e[(e.FRAME_INFO = 72)] = "FRAME_INFO");
})(Ce || (Ce = {})),
(function (e) {
(e[(e.ON_ABORT = 100)] = "ON_ABORT"),
(e[(e.WaitingRemoveDependencies = 101)] =
"WaitingRemoveDependencies"),
(e[(e.WxABReadEmptyContent = 102)] = "WxABReadEmptyContent");
})(Ee || (Ee = {})),
(function (e) {
(e[(e.WAIT_SUB_WASM_END = 30)] = "WAIT_SUB_WASM_END"),
(e[(e.BEFORE_LOAD_SUB_WASM = 31)] = "BEFORE_LOAD_SUB_WASM"),
(e[(e.LOAD_SUB_WASM_VERY_EARLY = 32)] = "LOAD_SUB_WASM_VERY_EARLY"),
(e[(e.SUB_WASM_LOAD = 33)] = "SUB_WASM_LOAD"),
(e[(e.SUB_WASM_COMPILED = 34)] = "SUB_WASM_COMPILED"),
(e[(e.FETCH_JS = 35)] = "FETCH_JS"),
(e[(e.WRITE_PATCH = 36)] = "WRITE_PATCH"),
(e[(e.COMPILE_PATCH = 37)] = "COMPILE_PATCH"),
(e[(e.DOWNLOAD_PATCH = 38)] = "DOWNLOAD_PATCH");
})(ke || (ke = {})),
(function (e) {
e[(e.Malloc = 110)] = "Malloc";
})(Ie || (Ie = {})),
(function (e) {
(e[(e.normal = 0)] = "normal"), (e[(e.codeSplit = 1)] = "codeSplit");
})(Pe || (Pe = {})),
(function (e) {
(e[(e.Normal = 0)] = "Normal"), (e[(e.WK = 1)] = "WK");
})(Re || (Re = {}));
var Le,
De,
Me,
xe,
Fe,
_e = { 1: "webgl", 2: "webgl2" };
!(function (e) {
(e.AdSpaceType = "adSpaceType"),
(e.AdType = "adType"),
(e.MaterialType = "materialType");
})(Le || (Le = {})),
(function (e) {
(e[(e.Default = 0)] = "Default"),
(e[(e.Min = 1)] = "Min"),
(e[(e.Max = 200)] = "Max");
})(De || (De = {})),
(function (e) {
(e[(e.Subpackage = 0)] = "Subpackage"), (e[(e.Cdn = 1)] = "Cdn");
})(Me || (Me = {})),
(function (e) {
(e.Wasm = "长时间未完成wasm代码下载"),
(e.DataPackage = "长时间未完成资源包下载");
})(xe || (xe = {})),
(function (e) {
(e.close = "0"), (e.open = "1");
})(Fe || (Fe = {}));
var Oe = "wasmsplit",
Ne = "filequota",
We = "wasmpatch",
Ue = (function () {
function e() {
var t;
u(this, e),
(this.config =
(l((t = {}), Oe, Fe.open),
l(t, Ne, Fe.open),
l(t, We, Fe.open),
l(t, "wxfont", Fe.open),
t));
}
return (
c(
e,
[
{
key: "init",
value: function (e) {
var t = this;
(null == e ? void 0 : e.length) &&
e.forEach(function (e) {
var n = e.key,
i = e.value;
t.set(n, i);
});
},
},
{
key: "get",
value: function (e) {
return this.config[e] || Fe.open;
},
},
{
key: "set",
value: function (e, t) {
this.config[e] = t || Fe.open;
},
},
{
key: "getFeatureString",
value: function () {
return Object.entries(this.config)
.map(function (e) {
var t = s(e, 2),
n = t[0],
i = t[1];
return "".concat(n, "_").concat(i);
})
.join(",");
},
},
{
key: "getFeatures",
value: function () {
return Object.assign({}, this.config);
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})().getInstance(),
Be = f(865).default,
Ge = (function () {
function e() {
u(this, e);
}
return (
c(e, null, [
{
key: "timeStart",
value: function (t) {
if (!e.timeMap.has(t)) {
var n = Date.now();
return e.timeMap.set(t, n), n;
}
return 0;
},
},
{
key: "printTime",
value: function (t) {
var n = t.indexOf("callMain耗时") > -1 && d.DO_RUN_START,
i = t.indexOf("wasm编译耗时") > -1 && d.WASM_BEGIN_TIME;
if (e.timeMap.has(t) || i || n) {
var a = e.timeEnd(t, !1),
r = "[PLUGIN TIME LOG "
.concat((0, _.p6)(Date.now(), "hh:mm.ss.SSS"), "] ")
.concat(t, ": ")
.concat(a, "ms");
Be.xlog.info(r),
se.log(r),
console.log(r),
e.timeStrList.push(r);
}
},
},
{
key: "timeEnd",
value: function (t) {
var n =
!(arguments.length > 1 && void 0 !== arguments[1]) ||
arguments[1],
i = t.indexOf("callMain耗时") > -1 && d.DO_RUN_START,
a = t.indexOf("wasm编译耗时") > -1 && d.WASM_BEGIN_TIME;
if (e.timeMap.has(t) || i || a) {
var r = Date.now(),
o = e.timeMap.get(t);
return (
i && (o = d.DO_RUN_START),
a && (o = d.WASM_BEGIN_TIME),
n && e.timeMap.delete(t),
r - o
);
}
return 0;
},
},
{
key: "getRuntime",
value: function () {
var t =
arguments.length > 0 &&
void 0 !== arguments[0] &&
arguments[0],
n = Date.now() - e.logStartTime;
return t ? +(n / 1e3).toFixed(2) : n;
},
},
{
key: "printRuntime",
value: function (t) {
var n = "[PLUGIN TIME LOG "
.concat((0, _.p6)(Date.now(), "hh:mm.ss.SSS"), "] ")
.concat(t, ": ")
.concat(e.getRuntime(), "ms");
Be.xlog.info(n),
se.log(n),
console.log(n),
n.indexOf("游戏启动耗时") > -1 &&
(e.timeStrList.push(n),
d.hideTimeLogModal ||
(!d.showTimeLogInAllVersion && K !== O.tE.DEVELOP) ||
(h.showModal({
title: "timelog",
content: e.timeStrList.join("\r\n"),
}),
(e.timeStrList = [])));
},
},
{
key: "storeTime",
value: function (t) {
e.storeTimeMap.has(t) ||
e.storeTimeMap.set(t, {
CostTimeMs: e.timeEnd(t),
RunTimeMs: e.getRuntime(),
});
},
},
{
key: "popTime",
value: function (t) {
if (e.storeTimeMap.has(t)) {
var n = e.storeTimeMap.get(t);
return e.storeTimeMap.delete(t), n;
}
return null;
},
},
]),
e
);
})();
(Ge.logStartTime = Date.now()),
(Ge.timeMap = new Map()),
(Ge.storeTimeMap = new Map()),
(Ge.timeStrList = []);
var Ve,
ze = (function () {
function e() {
u(this, e);
}
return (
c(e, null, [
{
key: "eventLog",
value: function () {
for (
var e,
t,
n,
i,
a,
r = arguments.length,
o = new Array(r),
s = 0;
s < r;
s++
)
o[s] = arguments[s];
var u = o[0],
c = void 0 === u ? "" : u;
o.length > 1 &&
(null === (n = null == c ? void 0 : c.includes) ||
void 0 === n
? void 0
: n.call(c, "fetch js:")) &&
(null ===
(a =
null === (i = ti.wasmSplitMonitor) || void 0 === i
? void 0
: i.recordSyncFetchTime) ||
void 0 === a ||
a.call(i)),
(e = Be.xlog).info.apply(e, ["[PLUGIN LOG] "].concat(o)),
se.log.apply(se, ["[PLUGIN LOG] "].concat(o)),
ee &&
(t = console).log.apply(
t,
[
"[PLUGIN LOG ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(o)
);
},
},
{
key: "debugLog",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
ee &&
$ &&
(e = console).log.apply(
e,
[
"[DEBUG LOG ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(n)
);
},
},
{
key: "debugWarn",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
ee &&
$ &&
(e = console).warn.apply(
e,
[
"[DEBUG WARN ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(n)
);
},
},
{
key: "debugError",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
ee &&
$ &&
(e = console).error.apply(
e,
[
"[DEBUG ERROR ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(n)
);
},
},
{
key: "pluginLog",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
se.log.apply(se, n),
ee &&
$ &&
(e = console).log.apply(
e,
[
"[PLUGIN LOG ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(n)
);
},
},
{
key: "pluginWarn",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
se.warn.apply(
se,
[
"".concat((0, _.p6)(Date.now(), "hh:mm.ss.SSS"), " "),
].concat(n)
),
ee &&
(e = console).warn.apply(
e,
[
"[PLUGIN WARN ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(n)
);
},
},
{
key: "pluginError",
value: function () {
for (
var e, t, n = arguments.length, i = new Array(n), a = 0;
a < n;
a++
)
i[a] = arguments[a];
se.warn.apply(
se,
[
"".concat((0, _.p6)(Date.now(), "hh:mm.ss.SSS"), " "),
].concat(i)
),
ue.error.apply(ue, ["[PLUGIN ERROR] "].concat(i)),
(e = Be.xlog).error.apply(e, ["[PLUGIN ERROR] "].concat(i)),
ee &&
(t = console).error.apply(
t,
[
"[PLUGIN ERROR ".concat(
(0, _.p6)(Date.now(), "hh:mm.ss.SSS"),
"] "
),
].concat(i)
);
},
},
{
key: "monitorLog",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
ee &&
(e = console).log.apply(e, ["[PLUGIN MONITOR] "].concat(n));
},
},
{
key: "monitorWarn",
value: function () {
for (
var e, t = arguments.length, n = new Array(t), i = 0;
i < t;
i++
)
n[i] = arguments[i];
ee &&
(e = console).warn.apply(e, ["[PLUGIN MONITOR] "].concat(n));
},
},
]),
e
);
})(),
je = f(729),
He = f.n(je),
qe = new (He())();
!(function (e) {
(e.PluginLaunch = "onPluginLaunch"),
(e.LoadingPageReady = "onLoadingPageReady"),
(e.ParallelLoading = "onParallelLoading"),
(e.ParallelLoaded = "onParallelLoaded"),
(e.WasmLoading = "onWasmLoading"),
(e.WasmLoaded = "onWasmLoaded"),
(e.AssetLoading = "onAssetLoading"),
(e.AssetLoaded = "onAssetLoaded"),
(e.AssetProcessed = "onAssetProcessed"),
(e.WasmInstantiated = "onWasmInstantiated"),
(e.CalledMain = "onCalledMain"),
(e.FileSystemReady = "onFileSystemReady"),
(e.FeatureFlagReady = "onFeatureFlagReady"),
(e.ReporterReady = "onReporterReady"),
(e.InstanceReady = "onInstanceReady"),
(e.ModulePrepared = "onModulePrepared"),
(e.LaunchProgress = "onLaunchProgress");
})(Ve || (Ve = {}));
var Qe = (function () {
function e() {
u(this, e);
}
return (
c(
e,
[
{
key: "init",
value: function (e) {
var t = e;
(this.unityManager = t), this.bindFunction();
},
},
{
key: "triggerEvent",
value: function (e, t) {
qe.emit(e, t);
},
},
{
key: "bindFunction",
value: function () {
var e = this;
Object.values(Ve).forEach(function (t) {
t === Ve.LaunchProgress
? (e.unityManager[t] = function (n) {
"function" == typeof n && qe.on(t, n),
e.unityManager.launchData.length &&
e.unityManager.launchData.forEach(function (n) {
return e.triggerEvent(t, n);
});
})
: (e.unityManager[t] = function (e) {
"function" == typeof e && qe.on(t, e);
});
});
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})().getInstance();
function Ke(e, t) {
for (
var n = arguments.length, a = new Array(n > 2 ? n - 2 : 0), r = 2;
r < n;
r++
)
a[r - 2] = arguments[r];
return i(e, [t].concat(a));
}
var Xe = c(function e(t) {
u(this, e),
(this.isVisible = !!t.isVisible),
(this.useCodeSplit = !!t.codeType),
(this.isHighPerformance = !!A.isWK),
(this.loadDataPackageFromSubpackage =
!!this.loadDataPackageFromSubpackage);
var n = !!Gn.getPrimaryDataCachePath();
(this.needDownloadDataPackage = !!n),
(this.loadingPageType = t.loadingPageType),
(this.features = Ue.getFeatures());
}),
Ze = (function (e) {
a(n, e);
var t = r(n);
function n(e, i, a) {
var r;
return (
u(this, n),
((r = t.call(this, e)).type = i),
(r.data = {
costTimeMs: a,
runTimeMs: Ge.getRuntime(),
isVisible: r.isVisible,
useCodeSplit: r.useCodeSplit,
isHighPerformance: r.isHighPerformance,
loadDataPackageFromSubpackage: r.loadDataPackageFromSubpackage,
needDownloadDataPackage: r.needDownloadDataPackage,
}),
delete r.isVisible,
delete r.useCodeSplit,
delete r.isHighPerformance,
delete r.loadDataPackageFromSubpackage,
delete r.needDownloadDataPackage,
delete r.loadingPageType,
delete r.features,
r
);
}
return c(n);
})(Xe),
Je = N.pixelRatio;
function Ye(e) {
return e * Je;
}
function $e(e) {
return e
.then(function (e) {
return [null, e];
})
.catch(function (e) {
return [e, null];
});
}
var et = (function () {
var e = [];
return function (t) {
return !(
"string" != typeof t ||
!(
t.includes("end of list") ||
t.includes("still waiting on run dependencies") ||
t.includes("dependency")
) ||
(!e.includes(t) && (e.push(t), 1))
);
};
})();
function tt(e) {
return !isNaN(e);
}
function nt(e) {
return tt(e) && Number.isInteger(e);
}
function it(e) {
var t = Number(e);
return t && !Number.isNaN(t) ? Number((t / ye / ye).toFixed(2)) : 0;
}
function at(e) {
var t = Number(e);
return t && !Number.isNaN(t) ? Number((t / ye).toFixed(2)) : 0;
}
function rt(e, t) {
return e
? e.getResponseHeader(t) || e.getResponseHeader(t.toLowerCase())
: "";
}
function ot(e, t) {
return e ? e[t] || e[t.toLowerCase()] : "";
}
var st = f(388),
ut = f(662).Z.wx;
function ct(e) {
(0, st.Mi)(e, ut.getNetworkType, ut.onNetworkStatusChange);
}
var lt = !0;
function ht(e) {
lt = e;
}
function dt() {
return lt;
}
var ft,
gt = 0;
function pt(e) {
(function (e) {
var t = Number(e);
return !(!nt(t) || t < 200 || t > 1e4);
})(e) && (gt = Number(e));
}
function mt() {
return gt;
}
function vt(e) {
return !!(nt(e) && e >= 0 && e <= 1e4);
}
!(function (e) {
(e.wifi = "wifi"),
(e.unknown = "unknow"),
(e.none = "none"),
(e["2g"] = "2g"),
(e["3g"] = "3g"),
(e["4g"] = "4g"),
(e["5g"] = "5g");
})(ft || (ft = {}));
var yt = (function () {
function e() {
u(this, e);
}
return (
c(e, null, [
{
key: "init",
value: function () {
ct(function (t) {
e.networkType = t;
});
},
},
]),
e
);
})();
(yt.networkType = ft["4g"]), yt.init();
var St,
Tt = f(54),
bt = f(835),
wt = h.getAccountInfoSync() || {},
Ct = ee && $,
Et = A.isWK && -1 === (0, _.yC)(N.SDKVersion, "2.20.1");
!(function (e) {
(e.False = "0"), (e.True = "1");
})(St || (St = {}));
var kt = c(function e(t) {
var n = this;
u(this, e),
Object.keys(t).forEach(function (e) {
n[e] = t[e];
});
});
function It() {
var e = dt() ? 1 : 0,
t = d,
n = t.unityVersion,
i = t.convertPluginVersion,
a = new kt({
PluginVersion: L,
IsVisible: e,
RuntimeType: A.isWK ? Re.WK : Re.Normal,
UnityVersion: n,
ConvertPluginVersion: i,
LibVersion: N.SDKVersion,
WechatClientVersion: N.version,
InstanceId: k || "",
});
return new Promise(function (e) {
ct(function (t) {
e(Object.assign(Object.assign({}, a), { NetworkType: t }));
});
});
}
var Pt,
Rt,
At,
Lt = Et
? { AppId: st.QD.STRING, AppVersion: st.QD.UINT, AppState: st.QD.UINT }
: {},
Dt = {
logid: 21492,
protocolParams: (Et ? ["AppId", "AppVersion", "AppState"] : []).concat([
"PluginVersion",
"IsDownloadCode",
"ReportType",
"CostTimeMs",
"NetworkType",
"RunTimeMs",
"PreloadedSize",
"Scene",
"LoadingPageType",
"ExternInfo",
"CodeType",
"IsVisible",
"BenchmarkLevel",
"RuntimeType",
"UnityVersion",
"ConvertPluginVersion",
"LibVersion",
"WechatClientVersion",
"DataPackageLoadType",
"AdSpaceType",
"AdType",
"MaterialType",
"ABTest",
"InstanceId",
]),
schemas: Object.assign(
Object.assign(
{
PluginVersion: st.QD.STRING,
IsDownloadCode: st.QD.UINT,
ReportType: st.QD.UINT,
CostTimeMs: st.QD.UINT,
NetworkType: st.QD.STRING,
RunTimeMs: st.QD.UINT,
PreloadedSize: st.QD.UINT,
Scene: st.QD.UINT,
LoadingPageType: st.QD.UINT,
ExternInfo: st.QD.STRING,
CodeType: st.QD.UINT,
IsVisible: st.QD.UINT,
BenchmarkLevel: st.QD.INT,
RuntimeType: st.QD.UINT,
UnityVersion: st.QD.STRING,
ConvertPluginVersion: st.QD.STRING,
LibVersion: st.QD.STRING,
WechatClientVersion: st.QD.STRING,
DataPackageLoadType: st.QD.UINT,
AdSpaceType: st.QD.UINT,
AdType: st.QD.UINT,
MaterialType: st.QD.UINT,
ABTest: st.QD.STRING,
InstanceId: st.QD.STRING,
},
Lt
)
),
asyncGetBase: It,
debug: Ct,
},
Mt = {
logid: 21493,
protocolParams: (Et ? ["AppId", "AppVersion", "AppState"] : []).concat([
"PluginVersion",
"NetworkType",
"IsDownloadCode",
"ReportType",
"ErrorMsg",
"RunTimeMs",
"Scene",
"LoadingPageType",
"ExternInfo",
"CodeType",
"ErrorType",
"IsVisible",
"BenchmarkLevel",
"RuntimeType",
"UnityVersion",
"ConvertPluginVersion",
"LibVersion",
"WechatClientVersion",
"DataPackageLoadType",
"AdSpaceType",
"AdType",
"MaterialType",
"ABTest",
"InstanceId",
]),
schemas: Object.assign(
Object.assign(
{
PluginVersion: st.QD.STRING,
NetworkType: st.QD.STRING,
IsDownloadCode: st.QD.UINT,
ReportType: st.QD.UINT,
ErrorMsg: st.QD.STRING,
RunTimeMs: st.QD.UINT,
Scene: st.QD.UINT,
LoadingPageType: st.QD.UINT,
ExternInfo: st.QD.STRING,
CodeType: st.QD.UINT,
ErrorType: st.QD.UINT,
IsVisible: st.QD.UINT,
BenchmarkLevel: st.QD.INT,
RuntimeType: st.QD.UINT,
UnityVersion: st.QD.STRING,
ConvertPluginVersion: st.QD.STRING,
LibVersion: st.QD.STRING,
WechatClientVersion: st.QD.STRING,
DataPackageLoadType: st.QD.UINT,
AdSpaceType: st.QD.UINT,
AdType: st.QD.UINT,
MaterialType: st.QD.UINT,
ABTest: st.QD.STRING,
InstanceId: st.QD.STRING,
},
Lt
)
),
asyncGetBase: It,
debug: Ct,
},
xt = {
logid: 21494,
protocolParams: (Et ? ["AppId", "AppVersion", "AppState"] : []).concat([
"PluginVersion",
"IsDownloadCode",
"NetworkType",
"RunTimeMs",
"StageType",
"Scene",
"LoadingPageType",
"ActionType",
"PositionID",
"ActionID",
"ExternInfo",
"CodeType",
"IsVisible",
"BenchmarkLevel",
"RuntimeType",
"UnityVersion",
"ConvertPluginVersion",
"LibVersion",
"WechatClientVersion",
"DataPackageLoadType",
"AdSpaceType",
"AdType",
"MaterialType",
"ABTest",
"InstanceId",
]),
schemas: Object.assign(
Object.assign(
{
PluginVersion: st.QD.STRING,
IsDownloadCode: st.QD.UINT,
NetworkType: st.QD.STRING,
RunTimeMs: st.QD.UINT,
StageType: st.QD.STRING,
Scene: st.QD.UINT,
LoadingPageType: st.QD.UINT,
ActionType: st.QD.UINT,
PositionID: st.QD.UINT,
ActionID: st.QD.UINT,
ExternInfo: st.QD.STRING,
CodeType: st.QD.UINT,
IsVisible: st.QD.UINT,
BenchmarkLevel: st.QD.INT,
RuntimeType: st.QD.UINT,
UnityVersion: st.QD.STRING,
ConvertPluginVersion: st.QD.STRING,
LibVersion: st.QD.STRING,
WechatClientVersion: st.QD.STRING,
DataPackageLoadType: st.QD.UINT,
AdSpaceType: st.QD.UINT,
AdType: st.QD.UINT,
MaterialType: st.QD.UINT,
ABTest: st.QD.STRING,
InstanceId: st.QD.STRING,
},
Lt
)
),
asyncGetBase: It,
debug: Ct,
};
if (Et) {
(Pt = new bt.Z(
Object.assign(Object.assign({}, Dt), {
reportType: st.C2.KvStat,
reportFunc: v,
})
)),
(Rt = new bt.Z(
Object.assign(Object.assign({}, Mt), {
reportType: st.C2.KvStat,
reportFunc: v,
})
)),
(At = new bt.Z(
Object.assign(Object.assign({}, xt), {
reportType: st.C2.KvStat,
reportFunc: v,
})
)),
Pt.setKvStatBase(N),
Rt.setKvStatBase(N),
At.setKvStatBase(N);
var Ft = new kt({ AppId: wt.miniProgram.appId, AppState: O.dg[K] });
Pt.setBase(Ft), Rt.setBase(Ft), At.setBase(Ft);
} else
(Pt = new Tt.Z(
Object.assign(Object.assign({}, Dt), {
reportFunc: m,
logid: "WXGameWASMLaunchTime",
})
)),
(Rt = new Tt.Z(
Object.assign(Object.assign({}, Mt), {
reportFunc: m,
logid: "WXGameWASMLaunchException",
})
)),
(At = new Tt.Z(
Object.assign(Object.assign({}, xt), {
reportFunc: m,
logid: "WXGameWASMLaunchClose",
})
));
var _t = d,
Ot = _t.bundleHashLength,
Nt = void 0 === Ot ? 32 : Ot,
Wt = _t.texturesHashLength,
Ut = void 0 === Wt ? 8 : Wt,
Bt = _t.texturesPath,
Gt = void 0 === Bt ? "Assets/Textures" : Bt,
Vt = _t.needCacheTextures,
zt = !1,
jt = "/",
Ht = "data.unityweb",
qt = "wasm.code.unityweb",
Qt = /[^:]\/{2,}/gi,
Kt = /\.[./]+/gi,
Xt = /[<>]+/gi,
Zt = /\\+/gi,
Jt = new RegExp("/?__GAME_FILE_CACHE");
function Yt() {
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
t[n] = arguments[n];
return (null == t ? void 0 : t.length)
? $t(
t
.filter(function (e) {
var t;
return !!(null === (t = null == e ? void 0 : e.trim) ||
void 0 === t
? void 0
: t.call(e));
})
.join(jt)
)
: "";
}
function $t(e) {
return (null == e ? void 0 : e.trim())
? e
.replace(Kt, "")
.replace(Xt, "")
.replace(Qt, function (e) {
return e.replace(/\/+/g, jt);
})
: "";
}
function en(e) {
var t,
n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "";
if (
!(null === (t = null == e ? void 0 : e.trim) || void 0 === t
? void 0
: t.call(e)) ||
e.endsWith(jt)
)
return "";
var i = n;
i && (i = i.startsWith(".") ? i : ".".concat(i));
var a = e.substring(e.lastIndexOf(jt) + 1);
return (
a.includes("?") && (a = a.substring(0, a.indexOf("?"))),
a.includes("#") && (a = a.substring(0, a.indexOf("#"))),
a
.replace(null == i ? void 0 : i.toLowerCase(), "")
.replace(null == i ? void 0 : i.toUpperCase(), "")
);
}
function tn(e) {
return e.substring(e.lastIndexOf(jt) + 1);
}
function nn(e) {
var t,
n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
if (
!(null === (t = null == e ? void 0 : e.trim) || void 0 === t
? void 0
: t.call(e))
)
return "";
var i = d.STREAMING_CDN || d.DATA_CDN,
a = e.replace(i, "").replace(me, "").replace(ge, "").replace(ve, "");
return (
n && (a = a.replace(Jt, "")),
(a = a.substring(0, a.lastIndexOf(jt)))
? a.startsWith(jt)
? a
: "/".concat(a)
: a
);
}
function an(e) {
var t,
n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
if (
!(null === (t = null == e ? void 0 : e.trim) || void 0 === t
? void 0
: t.call(e))
)
return "";
if (e.includes(ge)) return e;
var i = nn(e, n),
a = en(e);
if (!zt) {
zt = !0;
var r = Yt(i, a);
(r.includes("//") || r.includes("?")) &&
ze.pluginError(
r,
"缓存路径包含//或? 请检查DATA_CDN配置和请求URL是否匹配"
);
}
return Yt(n ? me : ge, i, a);
}
function rn(e) {
var t = en(e);
if (!t) return "";
var n = t.includes(Ht) || t.includes(qt),
i = e.includes(Gt),
a = ((n
? /([a-zA-Z0-9]{16}\.)/gi
: i
? new RegExp("(.[a-zA-Z0-9]{".concat(Ut, "})"))
: new RegExp("([_-][a-zA-Z0-9]{".concat(Nt, "})(\\.\\w+)*$"))
).exec(t) || [])[1];
return a ? t.replace(a, "") : t;
}
function on(e) {
var t = en(e);
if (!t) return "";
var n = t.includes(Ht) || t.includes(qt),
i = e.includes(Gt),
a = (
n
? /([a-zA-Z0-9]{16})\./gi
: i
? new RegExp("\\.([a-zA-Z0-9]{".concat(Ut, "})"))
: new RegExp("[_-]([a-zA-Z0-9]{".concat(Nt, "})(\\.\\w+)*$"))
).exec(t),
r = "";
return a && (r = s(a, 2)[1]), r || "";
}
function sn(e) {
var t;
return !(
!(null === (t = null == e ? void 0 : e.trim) || void 0 === t
? void 0
: t.call(e)) ||
"string" != typeof e ||
!e.includes("http")
);
}
function un(e) {
return !!sn(e) && (!(!Vt || !cn(e)) || d.isCacheableFile(e));
}
function cn(e) {
return !!sn(e) && !!e.includes(Gt);
}
function ln(e) {
var t = d.STREAMING_CDN || d.DATA_CDN,
n = d.streamingUrlPrefixPath || "",
i = e.match(/(http|https|ftp|file):\/\//),
a = e;
return i || (a = Yt(t, n, e)), a;
}
function hn(e) {
return A.isPC ? e.replace(Zt, jt) : e;
}
function dn(e) {
return !!e.includes("cloud.unity3d.com");
}
var fn,
gn = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
pn = (function () {
function e() {
u(this, e),
(this.inited = !1),
(this.fileStats = []),
(this.fileInfoMap = new Map()),
(this.dirs = []),
(this.fs = Q),
(this.totalSize = 0),
(this.isOldUser = !1),
(this.cacheDirInited = !1),
(this.firstInitPromise = this.init());
}
return (
c(
e,
[
{
key: "cleanAllCache",
value: function () {
return gn(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return e.abrupt(
"return",
(this.cleanAllCachePromise ||
(this.cleanAllCachePromise =
this.executeCleanAllTask()),
this.cleanAllCachePromise)
);
case 1:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "executeCleanAllTask",
value: function () {
return gn(
this,
void 0,
void 0,
n().mark(function e() {
var t;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(e.prev = 0),
this.fs.rmdirSync(me, !0),
(t = this.isOldUser),
(this.cacheDirInited = !1),
(e.next = 6),
this.init()
);
case 6:
return (
(this.isOldUser = t),
(this.cleanAllCachePromise = null),
e.abrupt("return", !0)
);
case 11:
return (
(e.prev = 11),
(e.t0 = e.catch(0)),
e.abrupt(
"return",
(ze.pluginError(
"删除插件缓存目录失败: ",
e.t0.errMsg || e.t0.message,
e.t0
),
(this.cleanAllCachePromise = null),
!1)
)
);
case 14:
case "end":
return e.stop();
}
},
e,
this,
[[0, 11]]
);
})
);
},
},
{
key: "createCacheDir",
value: function () {
var e = this.fs,
t = me;
try {
e.accessSync(t), (this.isOldUser = !0);
} catch (n) {
e.mkdirSync(t, !0),
ze.pluginWarn("".concat(t, "目录不存在,创建目录")),
(this.isOldUser = !1);
}
return this.isOldUser;
},
},
{
key: "init",
value: function () {
return gn(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return e.abrupt(
"return",
(this.initPromise ||
(this.initPromise = this.executeInit()),
this.initPromise)
);
case 1:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "executeInit",
value: function () {
return gn(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
this.cacheDirInited ||
((this.cacheDirInited = !0),
this.createCacheDir()),
(this.dirs = []),
(this.fileStats = []),
(this.fileInfoMap = new Map()),
(this.totalSize = 0),
(e.next = 7),
this.getStats()
);
case 7:
this.handleStats(),
this.calculateSize(),
(this.fileStats = []),
(this.initPromise = null),
this.inited && this.checkNeedReportStat(),
(this.inited = !0),
ze.eventLog(
"缓存文件数=",
this.fileInfoMap.size,
",总文件大小=",
this.totalSize
);
case 14:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "checkNeedReportStat",
value: function () {
this.totalSize >= Se
? Rt.send(
new kt({
ReportType: be.STAT_SIZE_EXCEED,
ErrorMsg: "ecceed_max_size",
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
fileCount: this.fileInfoMap.size,
totalSize: this.totalSize,
maxAllowSize: Se,
}),
})
)
: Rt.send(
new kt({
ReportType: be.STAT_SIZE_NORMAL,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
fileCount: this.fileInfoMap.size,
totalSize: this.totalSize,
maxAllowSize: Se,
}),
})
);
},
},
{
key: "removeOldCache",
value: function () {
var e = this,
t = this.getErasableFiles(),
n = {};
t.forEach(function (e) {
var t = "".concat(e.dirname, "/").concat(e.shortFilename),
i = "".concat(e.dirname, "/").concat(e.filename);
if (n[t]) {
n[t].sameFiles.push(i);
var a = n[t].latestTime;
e.lastAccessedTime > a &&
((n[t].latestFile = i),
(n[t].latestTime = e.lastAccessedTime));
} else n[t] = { sameFiles: [i], latestFile: i, latestTime: e.lastAccessedTime };
}),
Object.keys(n).forEach(function (t) {
n[t].sameFiles.length > 1 &&
e.removeFilesExclude(n[t].latestFile);
});
},
},
{
key: "mkdir",
value: function (e) {
var t = this,
n =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: me;
return new Promise(function (i, a) {
var r = Yt(n, e);
t.dirs.includes(r)
? i(null)
: t.fs.access({
path: r,
success: function () {
t.dirs.push(r), i(null);
},
fail: function () {
t.fs.mkdir({
dirPath: r,
recursive: !0,
success: function () {
t.dirs.push(r), i(null);
},
fail: function (e) {
if (e.errMsg.includes("exist")) return i(null);
a(e);
},
});
},
});
});
},
},
{
key: "removeFile",
value: function (e, t) {
var i = this;
return new Promise(function (a, r) {
return gn(
i,
void 0,
void 0,
n().mark(function i() {
var o,
s,
u = this;
return n().wrap(
function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (e) {
n.next = 2;
break;
}
return n.abrupt("return", void a());
case 2:
if (((n.t0 = this.initPromise), !n.t0)) {
n.next = 6;
break;
}
return (n.next = 6), this.initPromise;
case 6:
if (
(o = this.findFile(e, !0)) &&
(((s = o).isReadyToDelete = !0), t)
)
try {
Ge.timeStart("删除文件".concat(s.path)),
this.fs.unlink({
filePath: s.path,
success: function () {
var e = s.size,
t = u.totalSize - e;
u.fileInfoMap.delete(s.subPath),
(u.totalSize = t),
ze.debugLog(
"删除文件: "
.concat(
s.shortFilename,
", md5:"
)
.concat(s.md5, ",size:")
.concat(
at(s.size),
"KB,耗时:"
)
.concat(
Ge.timeEnd(
"删除文件".concat(s.path),
!0
),
"ms"
)
),
a();
},
fail: function (e) {
if (
(Rt.send(
new kt({
ReportType: be.DELETE_FILE,
ErrorMsg: e.errMsg,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "deletefile",
filepath: s.path,
totalSize: u.totalSize,
}),
})
),
e.errMsg.includes(
"no such file or directory"
))
) {
var t = s.size,
n = u.totalSize - t;
u.fileInfoMap.delete(s.subPath),
(u.totalSize = n);
}
r(e);
},
});
} catch (e) {
ze.pluginError(
"删除文件失败: ".concat(s.path),
e.errMsg || e.message,
e
),
this.init(),
Rt.send(
new kt({
ReportType: be.DELETE_FILE,
ErrorMsg: "".concat(
e.message || e.errMsg
),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "deletefile",
filepath: s.path,
totalSize: this.totalSize,
}),
})
),
r(e);
}
case 8:
case "end":
return n.stop();
}
},
i,
this
);
})
);
});
},
},
{
key: "removeFilesExclude",
value: function (e) {
return gn(
this,
void 0,
void 0,
n().mark(function t() {
var i,
a,
r,
o,
s = this;
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
if (
((i = rn(e)),
(a = on(e)),
(r = nn(e)),
e && e.trim() && i && a)
) {
t.next = 3;
break;
}
return t.abrupt("return");
case 3:
return (
(o = (o = this.findFilesByShortFilename(
i,
r
)).filter(function (e) {
return a && e.md5 && e.md5 !== a;
})).length &&
ze.pluginLog("删除".concat(i, "旧缓存")),
(t.next = 8),
Promise.all(
o.map(function (e) {
return gn(
s,
void 0,
void 0,
n().mark(function t() {
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
return (
(t.next = 2),
this.removeFile(
e.path,
!0
)
);
case 2:
case "end":
return t.stop();
}
},
t,
this
);
})
);
})
)
);
case 8:
case "end":
return t.stop();
}
},
t,
this
);
})
);
},
},
{
key: "getErasableFiles",
value: function () {
return Array.from(this.fileInfoMap.values())
.filter(function (e) {
var t = e.erasable,
n = e.isReadyToDelete;
return !!t && !n;
})
.filter(function (e) {
return (
!d.isErasableFile ||
d.isErasableFile({
path: "".concat(e.dirname, "/").concat(e.filename),
filename: e.filename,
shortFilename: e.shortFilename,
dirname: e.dirname,
lastAccessedTime: e.lastAccessedTime,
size: e.size,
md5: e.md5,
})
);
})
.sort(function (e, t) {
return e.lastAccessedTime - t.lastAccessedTime;
});
},
},
{
key: "releaseMemory",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0,
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: d.releaseMemorySize || 31457280;
return gn(
this,
void 0,
void 0,
n().mark(function i() {
var a,
r,
o,
s,
u,
c = this;
return n().wrap(
function (i) {
for (;;)
switch ((i.prev = i.next)) {
case 0:
if (
((a = this.getErasableFiles()),
(r = e - Se + this.totalSize),
e && a && a.length && !(r <= 0))
) {
i.next = 4;
break;
}
return i.abrupt(
"return",
yn.NO_NEED_RELEASE_MEMORY
);
case 4:
if (!(e > Se)) {
i.next = 6;
break;
}
return i.abrupt(
"return",
(ze.pluginWarn(
"所需存储容量"
.concat(it(e), "MB超过最大值")
.concat(it(Se), "MB, 不执行清理")
),
yn.EXCEED_MEMORY)
);
case 6:
(o = []), (s = r = t + r);
case 9:
if (!(r > 0)) {
i.next = 16;
break;
}
if ((u = a.shift())) {
i.next = 13;
break;
}
return i.abrupt("break", 16);
case 13:
u.isReadyToDelete ||
((u.isReadyToDelete = !0), o.push(u)),
(r -= u.size);
case 14:
i.next = 9;
break;
case 16:
return (
o.length &&
ze.eventLog(
"需要释放".concat(it(s), "MB存储空间")
),
(i.next = 19),
Promise.all(
o.map(function (e) {
return gn(
c,
void 0,
void 0,
n().mark(function t() {
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
return (
(t.next = 2),
this.removeFile(
e.path,
!0
)
);
case 2:
return t.abrupt(
"return",
t.sent
);
case 3:
case "end":
return t.stop();
}
},
t,
this
);
})
);
})
)
);
case 19:
return i.abrupt("return", yn.RELEASED_MEMORY);
case 20:
case "end":
return i.stop();
}
},
i,
this
);
})
);
},
},
{
key: "addFile",
value: function (e) {
var t = e.size,
n = e.path,
i = an(n);
if (!this.findFile(n)) {
var a = en(n),
r = nn(n),
o = {
path: i,
subPath: Yt(r, a),
size: t,
filename: a,
dirname: r,
shortFilename: rn(a),
md5: on(a),
lastAccessedTime: parseInt(
String(Date.now() / 1e3),
10
),
erasable: !0,
};
this.fileInfoMap.set(o.subPath, o), (this.totalSize += t);
}
},
},
{
key: "calculateSize",
value: function () {
var e,
n = this.fileInfoMap.values(),
i = 0,
a = t(n);
try {
for (a.s(); !(e = a.n()).done; ) {
i += e.value.size;
}
} catch (e) {
a.e(e);
} finally {
a.f();
}
this.totalSize = i;
},
},
{
key: "getUsedSize",
value: function () {
return (
ze.pluginLog(
"getUsedSize: "
.concat(ge, "目录总大小: ")
.concat(it(this.totalSize), "MB")
),
this.totalSize
);
},
},
{
key: "updateAccessTime",
value: function (e) {
var t =
arguments.length > 1 &&
void 0 !== arguments[1] &&
arguments[1];
if (
!(
e.includes("wxfile://") ||
e.includes("http://") ||
e.includes("https://")
) ||
e.includes(ge)
) {
var n = this.findFile(e);
n &&
((n.lastAccessedTime = parseInt(
String(Date.now() / 1e3),
10
)),
t &&
this.fs.readFile({
filePath: n.path,
success: function () {},
}));
}
},
},
{
key: "findFile",
value: function (e) {
var t =
arguments.length > 1 &&
void 0 !== arguments[1] &&
arguments[1];
if (!e || !e.trim()) return null;
var n = e.includes(pe),
i = nn(e, n),
a = en(e),
r = this.fileInfoMap.get(Yt(i, a));
return !r || (!t && r.isReadyToDelete) ? null : r;
},
},
{
key: "getFileInfo",
value: function (e) {
return this.findFile(e) || null;
},
},
{
key: "findFilesByShortFilename",
value: function (e, t) {
return this.getErasableFiles().filter(function (n) {
return n.shortFilename === e && n.dirname === t;
});
},
},
{
key: "isSameFile",
value: function (e, t) {
var n = nn(e),
i = en(e),
a = t.filename;
return n === t.dirname && i === a;
},
},
{
key: "checkFileExistInSystem",
value: function (e) {
var t;
return gn(
this,
void 0,
void 0,
n().mark(function i() {
var a;
return n().wrap(
function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (
null === (t = null == e ? void 0 : e.trim) ||
void 0 === t
? void 0
: t.call(e)
) {
n.next = 2;
break;
}
return n.abrupt("return", !1);
case 2:
return (
(a = an(e)),
(n.next = 5),
this.statAsyncCatch(a)
);
case 5:
return n.abrupt("return", !!n.sent);
case 6:
case "end":
return n.stop();
}
},
i,
this
);
})
);
},
},
{
key: "statAsyncCatch",
value: function (e, t) {
var n = this;
return new Promise(function (i) {
n.fs.stat({
path: e,
recursive: t,
success: function (e) {
i(e.stats);
},
fail: function (t) {
ze.pluginError(
"FileSystem_statAsyncCatch: ".concat(e, " "),
t.errMsg,
t
),
i(null);
},
});
});
},
},
{
key: "statSyncCatch",
value: function (e, t) {
var n = this.fs.statSync;
try {
return n(e, t);
} catch (t) {
return (
ze.pluginError(
"FileSystem_statSyncCatch: ".concat(e, " "),
t.errMsg || t.message,
t
),
Rt.send(
new kt({
ReportType: be.DEFAULT,
ErrorMsg: t.errMsg || t.message,
ExternInfo: JSON.stringify({ path: e, async: !1 }),
})
),
null
);
}
},
},
{
key: "handleStats",
value: function () {
var e = this,
t = this.fileStats;
t &&
Array.isArray(t) &&
t.forEach(function (t) {
var n = e.handleFileInfo(t);
e.fileInfoMap.set(Yt(n.dirname, n.filename), n);
});
},
},
{
key: "handleFileInfo",
value: function (e) {
var t = e.path,
n = e.stats,
i = hn(t),
a = en(i),
r = i.includes(pe),
o = nn(i, r);
return {
path: an(i, r),
subPath: Yt(o, a),
filename: a,
dirname: o,
shortFilename: rn(i),
md5: on(i),
size: n.size,
lastAccessedTime: n.lastAccessedTime,
erasable: r,
};
},
},
{
key: "getStats",
value: function () {
return gn(
this,
void 0,
void 0,
n().mark(function e() {
var t, i;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (((i = []), !this.inited)) {
e.next = 7;
break;
}
return (
(e.next = 4), this.statAsyncCatch(ge, !0)
);
case 4:
(e.t0 = e.sent), (e.next = 8);
break;
case 7:
e.t0 = this.statSyncCatch(ge, !0);
case 8:
(t = e.t0) &&
(i = Array.from(t).filter(function (e) {
return e.stats.isFile();
})),
(this.fileStats = i);
case 11:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
],
[
{
key: "getIntance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})(),
mn = [Math.pow(216, 3), Math.pow(216, 2), 216, 1];
function vn(e) {
var t = e.byteLength;
if (
e.slice(-8).every(function (e, t) {
return 11 + t === e;
})
) {
for (
var n = 1,
i = e.slice(-12, -8).reduce(function (e, t, n) {
return e + t * mn[n];
}, 0);
n <= i;
) {
var a = t - 12 - 6 * n,
r = e[a],
o = e[a + 1] + 200,
s = e[a + 2],
u = e[a + 3],
c = e[a + 4],
l = e[a + 5],
h = s * mn[0] + u * mn[1] + c * mn[2] + l;
(e[h] = r), (e[h + 1] = o), (n += 1);
}
for (
var d =
(e[t - 12 - 6 * (n - 1) - 1] << 8) + e[t - 12 - 6 * (n - 1) - 2],
f = 1;
f <= d;
f++
)
if (0 !== e[t - 12 - 6 * (n - 1) - 2 - f]) return [e.buffer, !1];
return [e.slice(0, t - 12 - 6 * (n - 1) - d - 2).buffer, !0];
}
if (
e.slice(-8).every(function (e, t) {
return 21 + t === e;
})
) {
for (var g = (e[t - 9] << 8) + e[t - 10], p = 1; p <= g; p++)
if (0 !== e[t - 10 - p]) return [e.buffer, !1];
return [e.slice(0, t - 8 - g - 2).buffer, !0];
}
return [e.buffer, !1];
}
!(function (e) {
(e[(e.config = 0)] = "config"), (e[(e.writeFile = 1)] = "writeFile");
})(fn || (fn = {}));
var yn,
Sn = (function () {
function e() {
u(this, e),
(this.listener = new Set()),
(this.inited = !1),
(this.supportWorkerFs = !1),
(this.supportSharedBuffer = !1),
(this.hasSetQuotaStatus = !1);
}
return (
c(
e,
[
{
key: "init",
value: function () {
var e = this;
try {
if (
((this.worker = h.createWorker(
"workers/response/index.js"
)),
this.worker &&
((this.inited = !0),
this.postSystemInfo(),
this.bindEvent()),
E)
) {
var t = Ue.get(Ne) === Fe.open;
E({
enable: t,
success: function () {
(e.hasSetQuotaStatus = !0), (e.supportWorkerFs = !t);
},
fail: function (e) {
Ue.set(Ne, Fe.close),
ze.pluginWarn("切换quotacontrol失败: ", e);
},
complete: function () {
e.printStatus();
},
});
}
} catch (e) {
ze.pluginError("创建worker失败", e), this.printStatus();
}
},
},
{
key: "postSystemInfo",
value: function () {
this.worker.postMessage({
type: fn.config,
payload: { systemInfo: N },
});
},
},
{
key: "printStatus",
value: function () {
if (this.supportWorkerFs)
return ze.eventLog("使用worker写文件");
var e = Ue.get(Ne) === Fe.open;
ze.eventLog(
E && e && A.isAndroid
? "使用主线程+quotacontrol写文件"
: "使用主线程写文件"
);
},
},
{
key: "bindEvent",
value: function () {
var e = this;
this.worker.onMessage(function (t) {
var n = t.type,
i = t.payload;
n === fn.writeFile &&
qe.emit("writeFile:".concat(i.filePath), i),
n === fn.config &&
(e.hasSetQuotaStatus ||
(e.supportWorkerFs = i.supportWorkerFs),
(e.supportSharedBuffer = i.supportSharedBuffer),
E || e.printStatus());
});
},
},
{
key: "writeFile",
value: function (e) {
var t = this;
return new Promise(function (n, i) {
var a = e.filePath,
r = e.data;
if (!t.listener.has(a)) {
t.listener.add(a);
var o = r;
t.supportSharedBuffer &&
((o = h.createSharedArrayBuffer(r.byteLength)),
new Uint8Array(o.buffer).set(new Uint8Array(r))),
t.worker.postMessage({
type: fn.writeFile,
payload: {
isSharedBuffer: t.supportSharedBuffer,
filePath: a,
data: o,
},
}),
qe.once("writeFile:".concat(a), function (e) {
t.listener.delete(a), e.isok ? n() : i(e.err);
});
}
});
},
},
],
[
{
key: "instance",
get: function () {
return (
e.privateInstance || (e.privateInstance = new e()),
e.privateInstance
);
},
},
]
),
e
);
})(),
Tn = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
bn = h.getFileSystemManager();
!(function (e) {
(e[(e.NO_NEED_RELEASE_MEMORY = 1)] = "NO_NEED_RELEASE_MEMORY"),
(e[(e.EXCEED_MEMORY = 2)] = "EXCEED_MEMORY"),
(e[(e.RELEASED_MEMORY = 3)] = "RELEASED_MEMORY"),
(e[(e.CANNOT_RELEASE = 4)] = "CANNOT_RELEASE");
})(yn || (yn = {}));
var wn = (function () {
function e() {
u(this, e);
}
return (
c(e, null, [
{
key: "checkIsNewUser",
value: function () {
return !e.fileSystem.isOldUser;
},
},
{
key: "statAsyncCatch",
value: function (e, t, n) {
return new Promise(function (i) {
bn.stat({
path: e,
recursive: t,
success: function (e) {
i(e.stats);
},
fail: function (a) {
n ||
Rt.send(
new kt({
ReportType: be.DEFAULT,
ErrorMsg: "".concat(a.errMsg),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "statAsyncCatch",
path: e,
recursive: t,
}),
})
),
i(null);
},
});
});
},
},
{
key: "checkFileExist",
value: function (e) {
try {
return bn.accessSync(e), !0;
} catch (e) {
return !1;
}
},
},
{
key: "getFileSize",
value: function (t) {
return Tn(
this,
void 0,
void 0,
n().mark(function i() {
var a;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
return (n.next = 2), e.statAsyncCatch(t);
case 2:
return (
(a = n.sent),
n.abrupt(
"return",
(a && (null == a ? void 0 : a.size)) || 0
)
);
case 4:
case "end":
return n.stop();
}
}, i);
})
);
},
},
{
key: "getMd5",
value: function (e) {
return new Promise(function (t, n) {
e
? (0, bn.getFileInfo)({
filePath: e,
success: function (e) {
var n = e.digest;
t(n);
},
fail: n,
complete: function () {},
})
: t("");
});
},
},
{
key: "readFile",
value: function (t, n) {
var i =
arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
return new Promise(function (a, r) {
var o = t;
i || (o = an(t)),
bn.readFile({
filePath: o,
encoding: n,
success: function (n) {
var r;
if (
(i &&
(o = Yt(
null !== (r = d.dataFileSubPrefix) && void 0 !== r
? r
: "",
en(t, ".txt")
)),
e.fileSystem.findFile(o) &&
e.fileSystem.updateAccessTime(o, i),
A.isIOS && !A.isWK)
) {
var u = vn(new Uint8Array(n.data)),
c = s(u, 1)[0];
n.data = c;
}
a(n.data);
},
fail: r,
});
});
},
},
{
key: "readCompressedFile",
value: function (e) {
return new Promise(function (t, n) {
bn.readCompressedFile({
filePath: e,
compressionAlgorithm: "br",
success: function (e) {
return t(e.data);
},
fail: n,
});
});
},
},
{
key: "readFileBuffer",
value: function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: 0,
n = arguments.length > 2 ? arguments[2] : void 0;
return new Promise(function (i, a) {
bn.readFile({
filePath: e,
position: t,
length: n,
success: function (e) {
i(e.data);
},
fail: a,
});
});
},
},
{
key: "readFileTrunk",
value: function (t) {
var i,
a =
arguments.length > 1 &&
void 0 !== arguments[1] &&
arguments[1];
return Tn(
this,
void 0,
void 0,
n().mark(function r() {
var o, u, c, l, h, f, g, p, m, v, y, S, T;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
return (n.next = 2), e.getFileSize(t);
case 2:
if ((o = n.sent)) {
n.next = 5;
break;
}
return n.abrupt("return", new ArrayBuffer(0));
case 5:
(u = t),
a &&
(u = Yt(
null !== (i = d.dataFileSubPrefix) &&
void 0 !== i
? i
: "",
en(t, ".txt")
)),
(c = e.fileSystem.findFile(u)) &&
e.fileSystem.updateAccessTime(c.path, a),
(l = new ArrayBuffer(o)),
(h = new Uint8Array(l)),
(f = 8e6),
(g = 0);
case 11:
if (!(g < o)) {
n.next = 21;
break;
}
return (
(p = Math.min(f, o - g)),
ze.pluginLog("read part:", g, p),
(n.next = 16),
e.readFileBuffer(t, g, p)
);
case 16:
(m = n.sent),
h.set(new Uint8Array(m).subarray(0, p), g),
m.byteLength > p &&
(ze.pluginWarn(
"读取"
.concat(t, "超过边界, byteLength: ")
.concat(m.byteLength, "; offset: ")
.concat(g, "; toread: ")
.concat(p)
),
Rt.send(
new kt({
ReportType: be.OUT_OF_RANGE,
ErrorMsg: "out of range",
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
size: m.byteLength,
offset: g,
toread: p,
filePath: t,
}),
})
));
case 18:
(g += f), (n.next = 11);
break;
case 21:
if (!A.isIOS || A.isWK) {
n.next = 24;
break;
}
return (
(v = vn(h)),
(y = s(v, 2)),
(S = y[0]),
(T = y[1]),
n.abrupt("return", (T && e.cleanAllCache(), S))
);
case 24:
return n.abrupt("return", l);
case 25:
case "end":
return n.stop();
}
}, r);
})
);
},
},
{
key: "downloadFileByXMLHttpRequest",
value: function (e) {
return new Promise(function (t, n) {
var i = new d.XMLHttpRequest();
i.open("GET", e),
(i.responseType = "arraybuffer"),
(i.onload = function () {
t(i);
}),
(i.onerror = function (e) {
n(e);
}),
(i.ontimeout = function () {
n(new Error("timeout"));
}),
(i.onabort = function () {
n(new Error("abort"));
}),
i.send();
});
},
},
{
key: "downloadFileAsync",
value: function (e) {
return new Promise(function (t, n) {
h.downloadFile({ url: e, timeout: 6e4, success: t, fail: n });
});
},
},
{
key: "removeExpiredFile",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 7,
t = bn.stat,
n = bn.unlinkSync;
t({
path: me,
recursive: !0,
success: function (t) {
Object.keys(t.stats).forEach(function (i) {
var a = t.stats[i].stats;
"/" !== a.path &&
a.isFile() &&
(Date.now() / 1e3 - 1e3 * a.lastAccessedTime) / 86400 >
e &&
(ze.pluginWarn(
"删除长时间未使用资源 ".concat(me, "/").concat(a.path)
),
n("".concat(me, "/").concat(a.path)));
});
},
});
},
},
{
key: "saveFileFS",
value: function (e, t) {
return new Promise(function (n, i) {
bn.saveFile({
tempFilePath: e,
filePath: t,
success: n,
fail: i,
});
});
},
},
{
key: "saveFile",
value: function (t, i) {
return Tn(
this,
void 0,
void 0,
n().mark(function a() {
var r, o, u, c, l, h, d, f, g, p;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (
((r = nn(t)),
(o = en(t)),
(u = an(t)),
!(c = e.fileSystem.findFile(t)))
) {
n.next = 3;
break;
}
return n.abrupt(
"return",
(ze.pluginLog(
"".concat(o, "已有缓存, 无须重复缓存")
),
Promise.resolve(c.path))
);
case 3:
return (
e.fileSystem.removeFilesExclude(t),
(l = hn(i)),
(n.next = 7),
e.getFileSize(l)
);
case 7:
return (
(h = n.sent),
(n.next = 10),
e.fileSystem.releaseMemory(h)
);
case 10:
if (
((n.t0 = n.sent),
(n.t1 = yn.EXCEED_MEMORY),
n.t0 !== n.t1)
) {
n.next = 14;
break;
}
return n.abrupt(
"return",
(ze.pluginWarn(
"saveFile: 空间不足,缓存".concat(o, "失败")
),
e.fileSystem.init(),
Promise.resolve(l))
);
case 14:
return (n.next = 16), e.fileSystem.mkdir(r);
case 16:
return (
Ge.timeStart("saveFile ".concat(u)),
(n.next = 19),
$e(e.saveFileFS(l, u))
);
case 19:
return (
(d = n.sent),
(f = s(d, 2)),
(g = f[0]),
(p = f[1]),
n.abrupt(
"return",
p
? (ze.debugLog(
"缓存文件:"
.concat(o, "成功,size: ")
.concat(at(h), "KB,耗时:")
.concat(
Ge.timeEnd("saveFile ".concat(u)),
"ms"
)
),
e.fileSystem.addFile({ size: h, path: t }),
Promise.resolve(p.savedFilePath))
: (ze.pluginError(
"".concat(o, "缓存失败:"),
g.errMsg || g.message,
g
),
e.fileSystem.init(),
Promise.resolve(l))
)
);
case 24:
case "end":
return n.stop();
}
}, a);
})
);
},
},
{
key: "writeFile",
value: function (t, i) {
return Tn(
this,
void 0,
void 0,
n().mark(function a() {
var r, o, s, u, c, l;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (((n.t0 = e.fileSystem.initPromise), !n.t0)) {
n.next = 4;
break;
}
return (n.next = 4), e.fileSystem.initPromise;
case 4:
if (
((r = nn(t)),
(o = en(t)),
(s = an(t)),
!(u = e.fileSystem.findFile(t)))
) {
n.next = 7;
break;
}
return n.abrupt(
"return",
(ze.pluginLog("".concat(o, "已有缓存")),
Promise.resolve(u.path))
);
case 7:
return (
(n.next = 9), e.fileSystem.removeFilesExclude(t)
);
case 9:
return (
(c = i.byteLength),
(n.next = 12),
e.fileSystem.releaseMemory(c)
);
case 12:
if ((l = n.sent) !== yn.EXCEED_MEMORY) {
n.next = 17;
break;
}
(n.t1 =
(ze.pluginError("空间不足,写入".concat(o, "失败;")),
e.fileSystem.init(),
Promise.reject(new Error("exceed memory")))),
(n.next = 26);
break;
case 17:
if (l !== yn.CANNOT_RELEASE) {
n.next = 21;
break;
}
(n.t2 = Promise.reject(
new Error("frequent writes in a short time")
)),
(n.next = 25);
break;
case 21:
return (n.next = 23), e.fileSystem.mkdir(r);
case 23:
Ge.timeStart("writeFile ".concat(o)),
(n.t2 = Sn.instance.supportWorkerFs
? e.workerWriteFile({
cachePath: s,
content: i,
fileSize: c,
filename: o,
path: t,
})
: e.normalWriteFile({
cachePath: s,
content: i,
fileSize: c,
filename: o,
path: t,
}));
case 25:
n.t1 = n.t2;
case 26:
return n.abrupt("return", n.t1);
case 27:
case "end":
return n.stop();
}
}, a);
})
);
},
},
{
key: "workerWriteFile",
value: function (t) {
var n = t.cachePath,
i = t.content,
a = t.fileSize,
r = t.path,
o = t.filename;
return new Promise(function (t, s) {
Sn.instance
.writeFile({ filePath: n, data: i })
.then(function () {
ze.debugLog(
"缓存 "
.concat(o, "成功;size: ")
.concat(at(a), "KB,耗时: ")
.concat(Ge.timeEnd("writeFile ".concat(o)), "ms")
),
e.fileSystem.addFile({ size: i.byteLength, path: r }),
t(n);
})
.catch(function (t) {
var n;
ze.pluginError(
"缓存 ".concat(o, "失败:"),
t,
",totalSize=",
e.fileSystem.totalSize,
",size: ",
at(a),
"KB,耗时:",
Ge.timeEnd("writeFile ".concat(o)),
"ms"
),
(null === (n = t.errMsg) || void 0 === n
? void 0
: n.includes("maximum")) &&
e.fileSystem.totalSize + i.byteLength <= Se &&
Rt.send(
new kt({
ReportType: be.QUOTA_CONTROL,
ErrorMsg: t.errMsg,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "quota_control_error",
filename: o,
size: i.byteLength,
totalSize: e.fileSystem.totalSize,
maxAllowSize: Se,
}),
})
),
e.fileSystem.totalSize + i.byteLength >= Se &&
Rt.send(
new kt({
ReportType: be.EXCEED_MAX,
ErrorMsg: t.errMsg,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "exceed_max_storage",
filename: o,
size: i.byteLength,
totalSize: e.fileSystem.totalSize,
}),
})
),
Rt.send(
new kt({
ReportType: be.WRITEFILE,
ErrorMsg: "".concat(t.errMsg),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "writefile",
filename: o,
size: i.byteLength,
totalSize: e.fileSystem.totalSize,
maxAllowSize: Se,
}),
})
),
e.fileSystem.init(),
s(t);
});
});
},
},
{
key: "normalWriteFile",
value: function (t) {
var n = t.cachePath,
i = t.content,
a = t.fileSize,
r = t.path,
o = t.filename;
return new Promise(function (t, s) {
bn.writeFile({
filePath: n,
data: i,
encoding: "binary",
success: function () {
ze.debugLog(
"缓存 "
.concat(o, "成功;size: ")
.concat(at(a), "KB,耗时: ")
.concat(Ge.timeEnd("writeFile ".concat(o)), "ms")
),
e.fileSystem.addFile({ size: i.byteLength, path: r }),
t(n);
},
fail: function (t) {
var n;
ze.pluginError(
"缓存 ".concat(o, "失败:"),
t.errMsg,
",totalSize=",
e.fileSystem.totalSize,
",size: ",
at(a),
"KB,耗时:",
Ge.timeEnd("writeFile ".concat(o)),
"ms",
t
),
(null === (n = t.errMsg) || void 0 === n
? void 0
: n.includes("maximum")) &&
e.fileSystem.totalSize + i.byteLength <= Se &&
Rt.send(
new kt({
ReportType: be.QUOTA_CONTROL,
ErrorMsg: t.errMsg,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "quota_control_error",
filename: o,
size: i.byteLength,
totalSize: e.fileSystem.totalSize,
maxAllowSize: Se,
}),
})
),
Rt.send(
new kt({
ReportType: be.WRITEFILE,
ErrorMsg: "".concat(t.errMsg),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
type: "writefile",
filename: o,
size: i.byteLength,
totalSize: e.fileSystem.totalSize,
maxAllowSize: Se,
}),
})
),
e.fileSystem.init(),
s(t);
},
});
});
},
},
{
key: "cleanAllCache",
value: function () {
return e.fileSystem.cleanAllCache();
},
},
{
key: "removeFile",
value: function (t) {
return e.fileSystem.removeFile(t, !0);
},
},
{
key: "getFileInfo",
value: function (t) {
return e.fileSystem.getFileInfo(t);
},
},
{
key: "getCachePath",
value: function (t) {
var n = e.getFileInfo(t);
return n ? n.path : "";
},
},
{
key: "readJson",
value: function (t) {
var i =
!(arguments.length > 1 && void 0 !== arguments[1]) ||
arguments[1];
return Tn(
this,
void 0,
void 0,
n().mark(function a() {
var r, o, u, c;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (!t) {
n.next = 10;
break;
}
return (n.next = 3), $e(e.readFile(t, "utf-8"));
case 3:
if (
((r = n.sent),
(o = s(r, 2)),
(u = o[0]),
!(c = o[1]))
) {
n.next = 9;
break;
}
return n.abrupt("return", JSON.parse(c));
case 9:
u &&
i &&
ze.pluginWarn(
"读取json: ".concat(t, "失败"),
u.errMsg || u.message,
u
);
case 10:
return n.abrupt("return", null);
case 11:
case "end":
return n.stop();
}
}, a);
})
);
},
},
{
key: "writeJson",
value: function (e, t) {
if (e && t) {
var n = JSON.stringify(t);
bn.writeFile({
filePath: e,
data: n,
encoding: "utf-8",
success: function () {
ze.pluginLog("写入json: ".concat(e, "成功"));
},
fail: function (t) {
ze.pluginWarn("写入json: ".concat(e, "失败"), t.errMsg, t);
},
});
}
},
},
{
key: "mkdir",
value: function (t) {
var i =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: me;
return Tn(
this,
void 0,
void 0,
n().mark(function a() {
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
return n.abrupt("return", e.fileSystem.mkdir(t, i));
case 1:
case "end":
return n.stop();
}
}, a);
})
);
},
},
]),
e
);
})();
wn.fileSystem = pn.getIntance();
var Cn = N.pixelRatio,
En = {},
kn = [-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, 1, 0],
In = [0, 1, 2, 0, 2, 3],
Pn = [0, 0, 1, 0, 1, 1, 0, 1];
function Rn(e, t, n) {
var i = e.createShader(n);
return (
e.shaderSource(i, t),
e.compileShader(i),
e.getShaderParameter(i, e.COMPILE_STATUS) ||
console.error(
"Error compiling shader: ".concat(e.getShaderInfoLog(i))
),
i
);
}
function An(e, t, n) {
if (e) {
e.frontFace(e.CCW),
(e.canvas.width = t * Cn),
(e.canvas.height = n * Cn),
e.viewport(0, 0, e.drawingBufferWidth, e.drawingBufferHeight);
var i = Rn(
e,
"\n attribute vec3 aPos;\n attribute vec2 aVertexTextureCoord;\n varying highp vec2 vTextureCoord;\n\n void main(void){\n gl_Position = vec4(aPos, 1);\n vTextureCoord = aVertexTextureCoord;\n }\n",
e.VERTEX_SHADER
),
a = Rn(
e,
"\n varying highp vec2 vTextureCoord;\n uniform sampler2D uSampler;\n\n void main(void) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n }\n",
e.FRAGMENT_SHADER
),
r = e.createProgram();
if (
(e.attachShader(r, i),
e.attachShader(r, a),
e.linkProgram(r),
e.getProgramParameter(r, e.LINK_STATUS))
) {
e.useProgram(r);
var o = e.createTexture();
e.activeTexture(e.TEXTURE0),
e.bindTexture(e.TEXTURE_2D, o),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE),
e.bindTexture(e.TEXTURE_2D, null),
(En.vertexBuffer = e.createBuffer()),
e.bindBuffer(e.ARRAY_BUFFER, En.vertexBuffer),
e.bufferData(e.ARRAY_BUFFER, new Float32Array(kn), e.STATIC_DRAW),
(En.vertexIndiceBuffer = e.createBuffer()),
e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, En.vertexIndiceBuffer),
e.bufferData(
e.ELEMENT_ARRAY_BUFFER,
new Uint16Array(In),
e.STATIC_DRAW
);
var s = e.getAttribLocation(r, "aPos");
e.vertexAttribPointer(s, 3, e.FLOAT, !1, 0, 0),
e.enableVertexAttribArray(s),
(En.trianglesTexCoordBuffer = e.createBuffer()),
e.bindBuffer(e.ARRAY_BUFFER, En.trianglesTexCoordBuffer),
e.bufferData(e.ARRAY_BUFFER, new Float32Array(Pn), e.STATIC_DRAW);
var u = e.getAttribLocation(r, "aVertexTextureCoord");
e.enableVertexAttribArray(u),
e.vertexAttribPointer(u, 2, e.FLOAT, !1, 0, 0);
var c = e.getUniformLocation(r, "uSampler");
return (
e.uniform1i(c, 0),
function (t) {
e.clearColor(0, 0, 0, 0),
e.clear(e.COLOR_BUFFER_BIT),
e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !0),
e.bindTexture(e.TEXTURE_2D, o),
e.texImage2D(
e.TEXTURE_2D,
0,
e.RGBA,
e.RGBA,
e.UNSIGNED_BYTE,
t
),
e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0),
e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1);
}
);
}
console.error("Unable to initialize the shader program.");
} else console.error("Unable to get webgl context.");
}
var Ln,
Dn,
Mn,
xn = (function () {
function e(t) {
u(this, e),
(this.useCoverView = t),
(this.renderer = null),
(this.offscreenCanvas = null),
this.useCoverView || this.init();
}
return (
c(
e,
[
{
key: "getRenderer",
value: function () {
return e.instance;
},
},
{
key: "refresh",
value: function () {
if (!this.useCoverView) {
var e = p.getContext("webgl", { alpha: 1 });
this.renderer = An(e, V, G);
}
},
},
{
key: "init",
value: function () {
if (!e.instance) {
var t = d.globalGL,
n = V,
i = G,
a = An(t, n, i),
r = h.createCanvas();
(r.width = n * U), (r.height = i * U);
var o = r.getContext("2d");
(this.renderer = a),
(this.offscreenCanvas = r),
(this.offscreenCtx = o),
(e.instance = this);
}
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance;
},
},
{
key: "getRenderer",
value: function () {
return e.instance;
},
},
]
),
e
);
})(),
Fn = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return u(this, n), ((e = t.apply(this, arguments)).destroyed = !1), e;
}
return (
c(n, [
{
key: "renderProgress",
value: function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: { progress: 0, originContent: "" },
n = t.progress,
i = t.originContent,
a = V,
r = G,
o = this.renderer,
s = this.offscreenCanvas,
u = this.offscreenCtx,
c = N.safeArea,
l = r - c.bottom;
if (u) {
u.clearRect(0, 0, Ye(a), Ye(r)),
(u.fillStyle = "rgba(0, 0, 0, 0.3)"),
u.fillRect(0, Ye(r - 48 - l), Ye(a), Ye(48 + l)),
(u.fillStyle = "rgb(151, 151, 151)"),
u.fillRect(
Ye((a - 320) / 2),
Ye(r - 36 - l),
Ye(320),
Ye(4)
),
(u.fillStyle = "rgba(255, 255, 255, 1)"),
u.fillRect(
Ye((a - 320) / 2),
Ye(r - 36 - l),
Ye(parseInt(String(320 * n), 10)),
Ye(4)
),
(u.font = "".concat(Ye(14), "px serif")),
(u.fillStyle = "#fff");
var h = 0;
i
? ((h = u.measureText(i).width), (u.textAlign = "start"))
: (u.textAlign = "center"),
u.fillText(
"".concat(e),
Ye((a - h / U) / 2),
Ye(r - 12 - l)
),
o(s);
}
},
},
{
key: "hideProgress",
value: function () {
if (!this.destroyed && !this.useCoverView) {
this.destroyed = !0;
var e = d.globalGL;
this.offscreenCtx.clearRect(0, 0, Ye(V), Ye(G)),
(this.renderer = null),
(this.offscreenCanvas = null),
(this.offscreenCtx = null),
e.clearColor(0, 0, 0, 0),
e.clear(e.COLOR_BUFFER_BIT);
}
},
},
]),
n
);
})(xn);
!(function (e) {
(e.DEFAULT = "DEFAULT"),
(e.PENDING = "PENDING"),
(e.FULFILLED = "FULFILLED"),
(e.REJECTED = "REJECTED");
})(Ln || (Ln = {}));
var _n = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "setProgress",
value: function (e) {
var t = this,
i =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: { progress: 0, status: Ln.DEFAULT },
a = i.progress,
r = i.status,
o = n.launchProgress[e];
if (
(this.updateStatus(o, r),
this.updateProgress(o, a || 0),
!this.useCoverView)
) {
var s = o.title,
u = o.status,
c = o.progress,
l = void 0 === c ? 0 : c,
h = o.fakeProgress,
d = o.previousStatus,
f = o.timer,
g = e > Te.PREPARE_GAME;
u === Ln.FULFILLED &&
f &&
(g || this.renderProgress("".concat(s), { progress: 100 }),
clearInterval(f),
(o.timer = null)),
g ||
(null == d
? void 0
: d.some(function (e) {
return n.launchProgress[e].status !== Ln.FULFILLED;
})) ||
(void 0 !== h && u !== Ln.FULFILLED
? (this.renderProgress("".concat(s), { progress: 0 }),
(o.timer = setInterval(function () {
var e = h || 0,
n = o.title;
if (o.status !== Ln.FULFILLED) {
var i = e + 5 > 100 ? 100 : e + 5;
o.fakeProgress = i;
var a = (n.match(/(\.)+/g) || [""])[0].length,
r = n.includes(".")
? n.replace(/(\.)+$/g, "...".substr(2 - a))
: "".concat(n, ".");
(o.title = r),
t.renderProgress("".concat(r), {
progress: i / 100,
originContent: n.replace(/(\.)+$/g, ""),
});
}
}, 700)))
: this.renderProgress(
""
.concat(s, " ")
.concat(l ? "".concat(l.toFixed(2), "%") : ""),
{ progress: l / 100 }
));
}
},
},
{
key: "updateStatus",
value: function (e, t) {
t &&
((e.status !== Ln.DEFAULT && e.status !== Ln.PENDING) ||
(e.status = t));
},
},
{
key: "updateProgress",
value: function (e, t) {
t && t <= 100 && (e.progress = t > 100 ? 100 : Math.max(t, 0));
},
},
]),
n
);
})(Fn);
(_n.launchProgress =
(l((o = {}), Te.LOAD_SUBPACKAGE, {
stage: "LOAD_SUBPACKAGE",
status: Ln.DEFAULT,
title: "分包下载中",
progress: 0,
previousStatus: [Te.LOAD_ASSETS],
priority: 1,
}),
l(o, Te.LOAD_ASSETS, {
stage: "LOAD_ASSETS",
status: Ln.DEFAULT,
title: "资源下载中",
progress: 0,
priority: 2,
}),
l(o, Te.UNZIP_ASSETS, {
stage: "UNZIP_ASSETS",
status: Ln.DEFAULT,
title: "资源解析中",
fakeProgress: 0,
timer: null,
previousStatus: [Te.LOAD_SUBPACKAGE],
priority: 3,
}),
l(o, Te.READ_ASSETS, {
stage: "READ_ASSETS",
status: Ln.DEFAULT,
title: "资源解析中",
fakeProgress: 0,
timer: null,
previousStatus: [Te.LOAD_SUBPACKAGE],
priority: 4,
}),
l(o, Te.COMPILE_WASM, {
stage: "COMPILE_WASM",
status: Ln.DEFAULT,
title: "资源编译中",
fakeProgress: 0,
timer: null,
previousStatus: [Te.READ_ASSETS],
priority: 5,
}),
l(o, Te.PREPARE_GAME, {
stage: "PREPARE_GAME",
status: Ln.DEFAULT,
title: "游戏初始化",
fakeProgress: 0,
timer: null,
previousStatus: [Te.COMPILE_WASM, Te.READ_ASSETS],
priority: 6,
}),
o)),
(function (e) {
(e.DEFAULT = "default"), (e.OK = "ok"), (e.ERROR = "error");
})(Dn || (Dn = {})),
(function (e) {
(e.LOADED = "loaded"), (e.ERROR = "error"), (e.COMPLETE = "complete");
})(Mn || (Mn = {}));
var On,
Nn = 200,
Wn = (function () {
function e(t) {
u(this, e),
(this.emitter = qe),
(this.url = t),
(this.localStatus = Dn.DEFAULT),
(this.localStatusCode = void 0),
(this.localResponse = "");
}
return (
c(e, [
{
key: "status",
get: function () {
return this.localStatus;
},
set: function (e) {
e && !this.localStatus && (this.localStatus = e);
},
},
{
key: "error",
get: function () {
return this.localError;
},
set: function (e) {
this.localError = e;
},
},
{
key: "statusCode",
get: function () {
return this.localStatusCode || 0;
},
set: function (e) {
void 0 === this.localStatusCode &&
Number.isInteger(e) &&
((this.localStatusCode = e),
this.status === Dn.DEFAULT &&
(this.status =
e && e >= 200 && e < 300 ? Dn.OK : Dn.ERROR));
},
},
{
key: "response",
get: function () {
return this.localResponse;
},
set: function (e) {
this.status === Dn.DEFAULT &&
(e
? ((this.status = Dn.OK), (this.localResponse = e))
: ((this.status = Dn.ERROR), (this.localResponse = "")));
},
},
{
key: "on",
value: function (e) {
var t = this;
return new Promise(function (n) {
t.status !== Dn.DEFAULT
? n(t)
: t.emitter.on(e, function () {
n(t);
});
});
},
},
{
key: "once",
value: function (e) {
var t = this;
return new Promise(function (n) {
t.emitter.once(e, function () {
n(t);
});
});
},
},
{
key: "emit",
value: function (e) {
this.emitter.emit(e);
},
},
]),
e
);
})(),
Un = (function () {
function e() {
u(this, e), (this.httpTasks = new Map());
}
return (
c(e, [
{
key: "isSameTask",
value: function (e, t) {
return e.url === t.url;
},
},
{
key: "hasTask",
value: function (e) {
return this.httpTasks.has(e.url);
},
},
{
key: "addTask",
value: function (e) {
this.hasTask(e) || this.httpTasks.set(e.url, e);
},
},
{
key: "removeTask",
value: function (e) {
this.hasTask(e) && this.httpTasks.delete(e.url);
},
},
{
key: "getTaskByUrl",
value: function (e) {
return e ? this.httpTasks.get(e) : null;
},
},
]),
e
);
})(),
Bn = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
Gn = (function (t) {
a(o, t);
var i = r(o);
function o() {
var t;
return (
u(this, o),
((t = i.apply(this, arguments)).loadDataPackageFromSubpackage = !1),
(t.compressDataPackage = !1),
(t.retryCount = 1),
(t.retryDuration = 1500),
(t.pendingDuration = 6e4),
(t.preloadDataProcessed = !1),
(t.releaseAblePaths = []),
(t.processRawData = function () {
var n;
Ge.timeStart("解析资源");
var i = e(t).unityManager;
if (!t.preloadDataProcessed) {
var a = i.gameInstance.Module.rawData;
t.preloadDataProcessed = !0;
var r = new Uint8Array(a),
o = new DataView(a),
s = 0,
u = "";
(a && t.checkPackageSize(a.byteLength)) ||
(u = "mismatch data size");
for (
var c = "",
l = "",
h = 0,
f = ["UnityWebData1.0\0", "TuanjieWebData1.0\0"];
h < f.length;
h++
) {
var g = f[h];
if (
(l = String.fromCharCode.apply(
null,
r.subarray(s, s + g.length)
)) === g
) {
c = l;
break;
}
}
if (
(ze.pluginLog("prefix", l),
c || u || (u = "unknown data format"),
u.length)
)
throw (
(t.handleDataError({
errMsg: u,
byteLength: null == a ? void 0 : a.byteLength,
defaultSize: t.defaultSize,
prefix: l,
}),
u)
);
s += c.length;
var p = o.getUint32(s, !0);
for (s += 4; s < p; ) {
var m = o.getUint32(s, !0);
s += 4;
var v = o.getUint32(s, !0);
s += 4;
var y = o.getUint32(s, !0);
s += 4;
var S = String.fromCharCode.apply(null, r.subarray(s, s + y));
s += y;
for (
var T = 0, b = S.indexOf("/", T) + 1;
b > 0;
T = b, b = S.indexOf("/", T) + 1
)
d.FS.createPath(
S.substring(0, T),
S.substring(T, b - 1),
!0,
!0
);
(null === (n = null == S ? void 0 : S.includes) ||
void 0 === n
? void 0
: n.call(S, "metadata.dat")) && t.releaseAblePaths.push(S),
d.FS.createDataFile(S, null, r.slice(m, m + v), !0, !0, !0);
}
(i.gameInstance.Module.rawData = null),
Ge.printTime("解析资源"),
Ge.timeEnd("解析资源"),
Qe.triggerEvent(Ve.AssetProcessed, Ke(Xe, i));
}
}),
(t.releaseDataPackage = function () {
t.releaseAblePaths.forEach(function (e) {
var t, n;
try {
null === (n = null == d ? void 0 : (t = d.FS).unlink) ||
void 0 === n ||
n.call(t, e);
} catch (e) {
ze.pluginError("删除首资源包meta段错误: ".concat(e.message));
}
});
}),
(t.loadAssetsByDownloadFile = function (i) {
return Bn(
e(t),
void 0,
void 0,
n().mark(function e() {
var t = this;
return n().wrap(function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return e.abrupt(
"return",
new Promise(function (e, a) {
var r = 0 === i,
o = t.unityManager,
u = Yt(d.DATA_CDN, t.downloadPath);
ze.eventLog("资源包下载url:".concat(u)),
Ge.timeStart("下载资源包耗时"),
o.launchStage.setProgress(Te.LOAD_ASSETS, {
status: Ln.PENDING,
}),
h
.downloadFile({
url: u,
timeout: 6e4,
success: function (i) {
return Bn(
t,
void 0,
void 0,
n().mark(function t() {
var u, c, l, h, d, f;
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
if (
((u = i.statusCode),
(c = i.tempFilePath),
u !== Nn)
) {
t.next = 14;
break;
}
if (
(Ge.printTime(
"下载资源包耗时"
),
o.triggerLaunchProgress(
Te.LOAD_ASSETS,
Ge.timeEnd(
"下载资源包耗时",
!1
)
),
Pt.send(
new kt({
ReportType:
Te.LOAD_ASSETS,
CostTimeMs:
Ge.timeEnd(
"下载资源包耗时"
),
RunTimeMs:
Ge.getRuntime(),
})
),
!this.compressDataPackage)
) {
t.next = 9;
break;
}
return (
(t.next = 5),
(0, _.zI)(
this.decompressPackage(
c
)
)
);
case 5:
return (
(l = t.sent),
(h = s(l, 1)),
(d = h[0]),
t.abrupt(
"return",
d ? a(d) : e()
)
);
case 9:
return (
Ge.timeStart(
"saveDataPackage"
),
(t.next = 12),
wn.saveFile(
this.cachePath,
c
)
);
case 12:
return (
(f = t.sent),
t.abrupt(
"return",
(ze.eventLog(
"资源包拷贝耗时".concat(
Ge.timeEnd(
"saveDataPackage"
),
"ms"
)
),
e(f))
)
);
case 14:
return t.abrupt(
"return",
(this.handleDownloadError(
u,
r
),
a(u))
);
case 15:
case "end":
return t.stop();
}
},
t,
this
);
})
);
},
fail: function (e) {
return t.handleDownloadError(e, r), a(e);
},
})
.onHeadersReceived(function (e) {
var n =
ot(e.header, "Content-Encoding") || "",
i =
!n.includes("gzip") &&
!n.includes("br");
ti.commonMonitor.recordAsset({
useContentEncoding:
!i || t.compressDataPackage,
}),
i &&
!t.compressDataPackage &&
console.error(
"你的CDN未开启对txt文件的gzip/br,会增加文件:".concat(
u,
" 的加载耗时!"
)
);
});
})
);
case 1:
case "end":
return e.stop();
}
}, e);
})
);
}),
(t.loadAssetsByXhr = function (i) {
return Bn(
e(t),
void 0,
void 0,
n().mark(function e() {
var t,
a,
r,
o = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(t = 0 === i),
(a = this.unityManager),
(r = Yt(d.DATA_CDN, this.downloadPath)),
e.abrupt(
"return",
(ze.eventLog("资源包下载url:".concat(r)),
Ge.timeStart("下载资源包耗时"),
new Promise(function (e, n) {
a.launchStage.setProgress(Te.LOAD_ASSETS, {
status: Ln.PENDING,
});
var i = new d.XMLHttpRequest();
i.open("GET", r),
(i.responseType = "arraybuffer"),
(i.timeout = 6e4),
(i.onload = function () {
var s = i.status;
if (s === Nn) {
Ge.printTime("下载资源包耗时"),
a.triggerLaunchProgress(
Te.LOAD_ASSETS,
Ge.timeEnd("下载资源包耗时", !1)
),
ti.commonMonitor.recordAsset({
duration: Ge.timeEnd(
"下载资源包耗时",
!1
),
contentLength:
i.response.byteLength,
}),
Pt.send(
new kt({
ReportType: Te.LOAD_ASSETS,
CostTimeMs:
Ge.timeEnd("下载资源包耗时"),
RunTimeMs: Ge.getRuntime(),
})
),
(a.gameInstance.Module.rawData =
i.response),
o.printBufferContent(i.response),
a.launchStage.setProgress(
Te.READ_ASSETS,
{ status: Ln.FULFILLED }
),
a.triggerLaunchProgress(
Te.READ_ASSETS,
0
),
Pt.send(
new kt({
ReportType: Te.READ_ASSETS,
CostTimeMs: 0,
RunTimeMs: Ge.getRuntime(),
})
),
wn.writeFile(o.cachePath, i.response);
var u = rt(i, "Content-Encoding") || "",
c =
!u.includes("gzip") &&
!u.includes("br");
ti.commonMonitor.recordAsset({
useContentEncoding:
!c || o.compressDataPackage,
}),
c &&
!o.compressDataPackage &&
console.error(
"你的CDN未开启对txt文件的gzip/br,会增加文件:".concat(
r,
" 的加载耗时!"
)
),
e();
} else o.handleDownloadError(s, t), n(i);
});
var s = function (e) {
o.handleDownloadError(e, t), n(e);
};
(i.onerror = function (e) {
s(e);
}),
(i.ontimeout = function () {
s(new Error("timeout"));
}),
(i.onabort = function () {
s(new Error("abort"));
}),
i.send();
}))
)
);
case 2:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(t.invokeLoadDataPackage = function (i) {
return Bn(
e(t),
void 0,
void 0,
n().mark(function e() {
var t = this;
return n().wrap(function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return e.abrupt(
"return",
new Promise(function (e, a) {
var r = 0 === i,
o = t.unityManager,
u = !1;
o.launchStage.setProgress(Te.LOAD_ASSETS, {
status: Ln.PENDING,
}),
Ge.timeStart("下载资源包");
var c = h.loadSubpackage({
name: "data-package",
success: function () {
return Bn(
t,
void 0,
void 0,
n().mark(function t() {
var i, r, u;
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
if (
(Ge.printTime("下载资源包"),
o.triggerLaunchProgress(
Te.LOAD_ASSETS,
Ge.timeEnd("下载资源包", !1)
),
ti.commonMonitor.recordAsset({
duration: Ge.timeEnd(
"下载资源包",
!1
),
useContentEncoding: !0,
}),
Pt.send(
new kt({
ReportType:
Te.LOAD_ASSETS,
CostTimeMs:
Ge.timeEnd(
"下载资源包"
),
RunTimeMs:
Ge.getRuntime(),
})
),
!this.compressDataPackage)
) {
t.next = 7;
break;
}
return (
(t.next = 3),
(0, _.zI)(
this.decompressPackage(
"data-package/".concat(
this.downloadFilename
)
)
)
);
case 3:
return (
(i = t.sent),
(r = s(i, 1)),
(u = r[0]),
t.abrupt(
"return",
u ? a(u) : e()
)
);
case 7:
wn.writeFile(
this.cachePath,
new ArrayBuffer(1)
),
e(
"data-package/".concat(
this.downloadFilename
)
);
case 8:
case "end":
return t.stop();
}
},
t,
this
);
})
);
},
fail: function (e) {
t.handleDownloadError(e, r), a(e);
},
complete: function () {
(u = !0),
o.launchStage.setProgress(Te.LOAD_ASSETS, {
progress: 100,
status: Ln.FULFILLED,
});
},
});
setTimeout(function () {
u ||
(ze.pluginError(xe.DataPackage),
a(new Error(xe.DataPackage)));
}, t.pendingDuration),
c.onProgressUpdate(function (e) {
var t = (
e.totalBytesWritten / 1048576
).toFixed(2),
n = (
e.totalBytesExpectedToWrite / 1048576
).toFixed(2);
X ||
ze.eventLog(
"资源包下载进度",
e.progress,
t,
"MB;",
n,
"MB"
),
o.launchStage.setProgress(Te.LOAD_ASSETS, {
progress: 100 * e.progress,
});
});
})
);
case 1:
case "end":
return e.stop();
}
}, e);
})
);
}),
t
);
}
return (
c(o, [
{
key: "init",
value: function (e, t) {
(this.unityManager = e), this.initConfig(t);
},
},
{
key: "loadDataPackage",
value: function () {
return Bn(
this,
void 0,
void 0,
n().mark(function e() {
var t, i, a, r, o;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((t = this.unityManager),
(i = this.downloadFilename),
(e.prev = 1),
Qe.triggerEvent(Ve.AssetLoading, Ke(Xe, t)),
this.loadDataPackageFromSubpackage
? ze.eventLog(
"通过小游戏分包加载资源",
i,
", 是否压缩=",
this.compressDataPackage
)
: ze.eventLog("通过CDN加载资源", i),
(a = this.getPrimaryDataCachePath()),
(o = wn.getFileInfo(a)),
!a || !(null == o ? void 0 : o.size))
) {
e.next = 16;
break;
}
if (
((r =
this.loadDataPackageFromSubpackage &&
!this.compressDataPackage
? "data-package/".concat(i)
: a),
ze.eventLog("从缓存加载首包资源"),
ze.pluginLog("加载路径: ", r),
(e.t0 =
this.loadDataPackageFromSubpackage &&
!this.compressDataPackage),
!e.t0)
) {
e.next = 13;
break;
}
return (
(e.next = 13), this.invokeLoadDataPackage(0)
);
case 13:
t.launchStage.setProgress(Te.LOAD_ASSETS, {
progress: 100,
status: Ln.FULFILLED,
}),
(e.next = 32);
break;
case 16:
if (
(ze.eventLog("首包资源无缓存,开始下载"),
!this.loadDataPackageFromSubpackage)
) {
e.next = 23;
break;
}
return (
(e.next = 20),
(0, _.gj)(
this.invokeLoadDataPackage,
this.retryCount,
this.retryDuration
)
);
case 20:
(r = e.sent), (e.next = 31);
break;
case 23:
if (!A.isWK || this.compressDataPackage) {
e.next = 28;
break;
}
return (
(e.next = 26),
(0, _.gj)(
this.loadAssetsByXhr,
this.retryCount,
this.retryDuration
)
);
case 26:
e.next = 31;
break;
case 28:
return (
(e.next = 30),
(0, _.gj)(
this.loadAssetsByDownloadFile,
this.retryCount,
this.retryDuration
)
);
case 30:
r = e.sent;
case 31:
t.launchStage.setProgress(Te.LOAD_ASSETS, {
progress: 100,
status: Ln.FULFILLED,
});
case 32:
if (((t.loadingCount -= 1), (e.t1 = r), !e.t1)) {
e.next = 37;
break;
}
return (e.next = 37), this.readDataPackage(r);
case 37:
return (
ti.commonMonitor.recordAsset({
contentLength:
t.gameInstance.Module.rawData.byteLength,
}),
Qe.triggerEvent(Ve.AssetLoaded, Ke(Xe, t)),
e.abrupt("return", Promise.resolve())
);
case 42:
return (
(e.prev = 42),
(e.t2 = e.catch(1)),
e.abrupt(
"return",
(ze.pluginError(
"加载资源异常 ",
e.t2.errMsg || e.t2.message,
e.t2
),
Promise.reject(e.t2))
)
);
case 45:
case "end":
return e.stop();
}
},
e,
this,
[[1, 42]]
);
})
);
},
},
{
key: "getPrimaryDataCachePath",
value: function () {
return wn.getCachePath(this.cachePath);
},
},
{
key: "readDataPackage",
value: function (e) {
return Bn(
this,
void 0,
void 0,
n().mark(function t() {
var i, a, r;
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
if (((i = this.unityManager), !e)) {
t.next = 26;
break;
}
if (
(i.launchStage.setProgress(Te.READ_ASSETS, {
status: Ln.PENDING,
}),
Ge.timeStart("读取资源文件"),
(t.prev = 3),
!A.isWK && !A.isPC)
) {
t.next = 10;
break;
}
return (
(t.next = 7),
wn.readFile(
e,
void 0,
this.loadDataPackageFromSubpackage
)
);
case 7:
(i.gameInstance.Module.rawData = t.sent),
(t.next = 13);
break;
case 10:
return (
(t.next = 12),
wn.readFileTrunk(
e,
this.loadDataPackageFromSubpackage
)
);
case 12:
i.gameInstance.Module.rawData = t.sent;
case 13:
i.launchStage.setProgress(Te.READ_ASSETS, {
status: Ln.FULFILLED,
}),
Ge.printTime("读取资源文件"),
this.printBufferContent(
i.gameInstance.Module.rawData
),
i.triggerLaunchProgress(
Te.READ_ASSETS,
Ge.timeEnd("读取资源文件", !1)
),
Pt.send(
new kt({
ReportType: Te.READ_ASSETS,
CostTimeMs: Ge.timeEnd("读取资源文件"),
RunTimeMs: Ge.getRuntime(),
})
),
(t.next = 25);
break;
case 20:
(t.prev = 20),
(t.t0 = t.catch(3)),
(a = "string" == typeof t.t0),
(r = t.t0),
"number" == typeof t.t0 ||
a ||
(r = t.t0.errMsg || t.t0.message),
this.handleDataError({ errMsg: r });
case 25:
return t.abrupt("return", Promise.resolve());
case 26:
return t.abrupt(
"return",
Promise.reject("need asset path")
);
case 27:
case "end":
return t.stop();
}
},
t,
this,
[[3, 20]]
);
})
);
},
},
{
key: "decompressPackage",
value: function (e) {
return Bn(
this,
void 0,
void 0,
n().mark(function t() {
var i, a, r, o, u, c;
return n().wrap(
function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
return (
(i = this.unityManager).launchStage.setProgress(
Te.UNZIP_ASSETS,
{ status: Ln.PENDING }
),
Ge.timeStart("解压资源包耗时"),
(t.next = 4),
(0, _.zI)(wn.readCompressedFile(e))
);
case 4:
if (
((a = t.sent),
(r = s(a, 2)),
(o = r[0]),
(u = r[1]),
i.launchStage.setProgress(Te.UNZIP_ASSETS, {
status: Ln.FULFILLED,
}),
Ge.printTime("解压资源包耗时"),
!o && (null == u ? void 0 : u.byteLength))
) {
t.next = 11;
break;
}
return (
(c =
(null == o ? void 0 : o.errMsg) ||
"empty content"),
t.abrupt(
"return",
(Rt.send({
ReportType: Te.UNZIP_ASSETS,
ErrorMsg: c,
RunTimeMs: Ge.getRuntime(),
}),
ze.pluginError(
"解压资源失败, 加载方式: ".concat(
this.loadDataPackageFromSubpackage
? "分包"
: "CDN",
", errMsg: "
),
c
),
Promise.reject(o || c))
)
);
case 11:
return t.abrupt(
"return",
(i.triggerLaunchProgress(
Te.UNZIP_ASSETS,
Ge.timeEnd("下载资源包耗时", !1)
),
Pt.send(
new kt({
ReportType: Te.UNZIP_ASSETS,
CostTimeMs: Ge.timeEnd("解压资源包耗时"),
RunTimeMs: Ge.getRuntime(),
})
),
(i.gameInstance.Module.rawData = u),
this.printBufferContent(u),
wn.writeFile(this.cachePath, u),
Promise.resolve(u))
);
case 12:
case "end":
return t.stop();
}
},
t,
this
);
})
);
},
},
{
key: "handleDownloadError",
value: function (e, t) {
var n = "number" == typeof e,
i = "string" == typeof e,
a = e;
if (
(n || i || (a = e.errMsg || e.message),
ze.pluginError(
"loadType=",
this.loadDataPackageFromSubpackage ? "subpackage" : "cdn",
"下载资源包失败: ",
"statusCode=",
!!n && a,
", networkType=",
yt.networkType,
", isVisible=",
dt(),
", errMsg=",
a,
", error=",
e
),
n || i || console.error(e),
Rt.send(
new kt({
ReportType: Te.LOAD_ASSETS,
ErrorMsg: "".concat(a),
RunTimeMs: Ge.getRuntime(),
})
),
t)
) {
var r =
!A.isPC && a === xe.DataPackage && !!h.restartMiniProgram;
ze.pluginError(
"资源包下载最终失败",
", networkType=",
yt.networkType,
", isVisible=",
dt()
),
h.showModal({
title: "资源下载失败",
content: ""
.concat(a)
.concat(
A.isPC && a === xe.Wasm
? "\n请从 微信-小程序-最近使用 重新打开"
: ""
),
confirmText: r ? "重启游戏" : "确定",
showCancel: !1,
success: function () {
r && h.restartMiniProgram({});
},
});
}
},
},
{
key: "checkPackageSize",
value: function (e) {
var t =
!Number.isNaN(this.defaultSize) && e === this.defaultSize,
n = !Number.isNaN(this.optimalSize) && e === this.optimalSize;
return (
ze.eventLog(
"[datapackage] fileSize="
.concat(e, ", defaultSize=")
.concat(this.defaultSize, ", optimalSize=")
.concat(this.optimalSize)
),
t || n
);
},
},
{
key: "initConfig",
value: function (e) {
var t = e || {},
n = t.loadDataPackageFromSubpackage,
i = t.compressDataPackage;
(this.loadDataPackageFromSubpackage = !!n),
(this.compressDataPackage = !!i);
var a = d,
r = a.DATA_FILE_MD5,
o = a.GAME_NAME,
s = a.DATA_FILE_SIZE,
u = a.OPT_DATA_FILE_SIZE;
this.cacheFilename = ""
.concat(r, ".")
.concat(o, ".data.unityweb.bin");
var c = d.dataFileSubPrefix || "";
this.compressDataPackage
? (this.downloadFilename = "".concat(
this.cacheFilename,
".br"
))
: (this.downloadFilename = "".concat(
this.cacheFilename,
".txt"
)),
(this.unityManager.gameInstance.Module.preLoaDataPath =
this.downloadFilename),
(this.cachePath = Yt(c, this.cacheFilename)),
(this.downloadPath = Yt(c, this.downloadFilename)),
(this.defaultSize = Number(s)),
(this.optimalSize = Number(u));
},
},
{
key: "handleDataError",
value: function (e) {
var t,
n = e.errMsg,
i = e.byteLength,
a = e.defaultSize,
r = e.optimalSize,
o = e.prefix;
(this.loadDataPackageFromSubpackage &&
!this.compressDataPackage) ||
wn.removeFile(this.cachePath),
se.warn(n),
ue.error(n),
null === (t = null == d ? void 0 : d.onCrash) ||
void 0 === t ||
t.call(d),
Rt.send(
new kt({
ReportType: Te.READ_ASSETS,
ErrorMsg: n,
ExternInfo: JSON.stringify({
byteLength: i,
defaultSize: a,
optimalSize: r,
prefix: o,
}),
})
);
},
},
{
key: "printBufferContent",
value: function (e) {
e &&
ze.eventLog(
"[datapackage] content=",
new Uint8Array(e, 0, 64).toString()
);
},
},
]),
o
);
})(ce).getInstance(),
Vn = {
haventUseCodeSplit: "未使用wasm代码分包",
largeAssetPackage: "首资源包较大",
noContentEncoding: "首资源包未开启服务器压缩",
longCallmainCost: "callmain耗时较长,请用安卓cpuprofile分析热点函数",
},
zn = (function () {
function e(t, n) {
u(this, e),
(this.unityManager = t),
(this.monitor = n),
(this.result = {}),
(this.assetPerformance = {}),
(this.wasmPerformance = {}),
(this.callmainPerformance = {});
}
return (
c(e, [
{
key: "recordAsset",
value: function (e) {
this.assetPerformance = Object.assign(
Object.assign({}, this.assetPerformance),
e
);
},
},
{
key: "recordWasm",
value: function (e) {
this.wasmPerformance = Object.assign(
Object.assign(Object.assign({}, this.wasmPerformance), e),
{ useCodeSplit: this.unityManager.codeType === Pe.codeSplit }
);
},
},
{
key: "recordCallmain",
value: function (e) {
this.callmainPerformance = Object.assign(
Object.assign({}, this.callmainPerformance),
e
);
},
},
{
key: "reset",
value: function () {
(this.assetPerformance = {}),
(this.wasmPerformance = {}),
(this.callmainPerformance = {}),
(Vn = null);
},
},
{
key: "showResult",
value: function () {
return (this.result = this.getResultInfo()), this.checkResult();
},
},
{
key: "checkResult",
value: function () {
ze.monitorLog("----启动数据监控 start----"),
ze.monitorLog("启动基本信息: ", this.result);
var e = [],
t = this.result,
n = Gn.getPrimaryDataCachePath();
return (
t.useCodeSplit || e.push(Vn.haventUseCodeSplit),
+t.assetContentLength > 15728640 &&
e.push(Vn.largeAssetPackage),
Gn.loadDataPackageFromSubpackage ||
t.useContentEncoding ||
n ||
e.push(Vn.noContentEncoding),
A.isIOS &&
+t.callmainCost > 1500 &&
e.push(Vn.longCallmainCost),
A.isAndroid &&
+t.callmainCost > 3e3 &&
e.push(Vn.longCallmainCost),
e.length &&
(ze.monitorWarn("启动优化建议:"),
ze.monitorWarn(e.join("\n"))),
ze.monitorLog("----启动数据监控 end----"),
e
);
},
},
{
key: "getResultInfo",
value: function () {
return {
assetLoadCost: this.assetPerformance.duration || 0,
assetContentLength: this.assetPerformance.contentLength || 0,
useContentEncoding:
!!this.assetPerformance.useContentEncoding,
wasmLoadCost: this.wasmPerformance.duration || 0,
wasmContentLength: this.wasmPerformance.contentLength || 0,
useCodeSplit: !!this.wasmPerformance.useCodeSplit,
callmainCost: this.callmainPerformance.duration,
launchTime: this.callmainPerformance.launchTime,
};
},
},
]),
e
);
})();
!(function (e) {
(e[(e.Ok = 0)] = "Ok"), (e[(e.Fail = 1)] = "Fail");
})(On || (On = {}));
var jn = new ((function () {
function e() {
var t = this;
u(this, e),
(this.loadingCount = 0),
(this.loadedCount = 0),
(this.totalNetworkTime = 0),
(this.maxLoadingCount = 0),
(this.avgLoadingCount = 1),
(this.timer = 0),
(this.loadingStartTime = 0),
(this.tasks = new Map()),
(this.taskIdMap = new Map()),
(this.doRecord = function () {
t.loadingCount > t.maxLoadingCount &&
(t.maxLoadingCount = t.loadingCount),
(t.avgLoadingCount = Math.ceil(
(t.loadingCount + t.avgLoadingCount) / 2
)),
(t.timer = setTimeout(t.doRecord, 1e3));
});
}
return (
c(e, [
{
key: "genTask",
value: function (e, t) {
var n = new Hn({ url: e, taskId: t });
return t || this.addTaskId(n), this.addTask(n), n;
},
},
{
key: "addTask",
value: function (e) {
0 === this.loadingCount && (this.loadingStartTime = Date.now()),
(this.loadingCount += 1),
1 === this.loadingCount && this.doRecord(),
this.tasks.set(
"".concat(e.info.url, "@").concat(e.taskId),
e
);
},
},
{
key: "removeTask",
value: function (e) {
if (
((this.loadingCount -= 1),
(this.loadedCount += 1),
0 === this.loadingCount)
) {
var t = Date.now() - this.loadingStartTime;
(this.totalNetworkTime += t), this.stopRecord();
}
this.removeTaskId(e),
this.tasks.delete(
"".concat(e.info.url, "@").concat(e.taskId)
);
},
},
{
key: "getTask",
value: function (e, t) {
var n = t || this.getCurrentTaskId(e);
return this.tasks.get("".concat(e, "@").concat(n));
},
},
{
key: "addTaskId",
value: function (e) {
var t = this.taskIdMap.get(e.info.url);
t
? (t.push(e.taskId), this.taskIdMap.set(e.info.url, t))
: this.taskIdMap.set(e.info.url, [e.taskId]);
},
},
{
key: "removeTaskId",
value: function (e) {
var t = this.taskIdMap.get(e.info.url);
(null == t ? void 0 : t.length) &&
(t.pop(),
0 === t.length && this.taskIdMap.delete(e.info.url));
},
},
{
key: "getCurrentTaskId",
value: function (e) {
var t = this.taskIdMap.get(e),
n = null == t ? void 0 : t.length;
if (n && t) return t[n - 1];
},
},
{
key: "stopRecord",
value: function () {
this.timer && (clearTimeout(this.timer), (this.timer = 0));
},
},
]),
e
);
})())(),
Hn = (function () {
function e(t) {
u(this, e), this.init(t), this.triggerBeforeRequest();
}
return (
c(e, [
{
key: "init",
value: function (e) {
(this.info = { url: e.url, startTime: Date.now() }),
(this.taskId = e.taskId || (0, _.hQ)(10, !0));
},
},
{ key: "genResult", value: function () {} },
{
key: "requestSuccess",
value: function (e) {
var t =
arguments.length > 1 &&
void 0 !== arguments[1] &&
arguments[1];
(this.status = On.Ok),
t ? this.xhrRequestSuccess(e) : this.wxRequestSuccess(e),
this.handleComplete(),
this.triggerAfterSuccess();
},
},
{
key: "requestFail",
value: function (e) {
(this.status = On.Fail),
this.handleComplete(),
this.triggerAfterFail();
},
},
{
key: "triggerBeforeRequest",
value: function () {
var e;
this.beforeRequest &&
(null === (e = this.beforeRequest) ||
void 0 === e ||
e.call(this, this));
},
},
{
key: "triggerAfterSuccess",
value: function () {
var e;
this.afterSuccess &&
(null === (e = this.afterSuccess) ||
void 0 === e ||
e.call(this, this));
},
},
{
key: "triggerAfterFail",
value: function () {
var e;
this.afterFail &&
(null === (e = this.afterFail) ||
void 0 === e ||
e.call(this, this));
},
},
{
key: "xhrRequestSuccess",
value: function (e) {
if (
((this.info.statusCode = e.status),
this.info.statusCode === Nn)
) {
var t = e.originXhr || e;
this.setProfile(t.profile),
this.checkContentEncoding(rt(t, "Content-Encoding")),
this.checkCDNCache(
rt(t, "X-Cache-Lookup") || rt(t, "X-Cache"),
rt(t, "Age")
),
this.setContentLength(e.response),
(this.info.cacheable = e.cacheable),
(this.info.isReadFromCache = !!e.isReadFromCache),
(this.info.isTexture = !!cn(this.info.url));
}
},
},
{
key: "wxRequestSuccess",
value: function (e) {
(this.info.statusCode = e.statusCode),
200 === this.info.statusCode &&
(this.setProfile(e.profile),
this.checkContentEncoding(ot(e.header, "Content-Encoding")),
this.checkCDNCache(
ot(e.header, "X-Cache-Lookup") || ot(e.header, "X-Cache"),
ot(e.header, "Age")
),
this.setContentLength(e.data));
},
},
{
key: "checkContentEncoding",
value: function (e) {
var t = (e || "").toLowerCase();
this.info.enableContentEncoding =
t.includes("gzip") || t.includes("br");
},
},
{
key: "checkCDNCache",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: "",
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: "",
n = (e || "").toLowerCase();
this.info.hitCache = n
? n.includes("hit")
: !!t && Number(t) > 0;
},
},
{
key: "setProfile",
value: function (e) {
e &&
((this.info.receivedBytedCount = e.receivedBytedCount || 0),
(this.info.protocol = e.protocol),
e.requestEnd &&
e.requestStart &&
((this.info.duration = e.requestEnd - e.requestStart),
(this.info.pendingDuration =
e.requestStart - this.info.startTime)));
},
},
{
key: "handleComplete",
value: function () {
(this.info.endTime = Date.now()),
(this.info.duration =
this.info.duration ||
this.info.endTime - this.info.startTime),
(this.info.pendingDuration = this.info.pendingDuration || 0);
},
},
{
key: "setContentLength",
value: function (e) {
if ("string" == typeof e)
this.info.receivedBytedCount = e.length;
else if (e.byteLength)
this.info.receivedBytedCount = e.byteLength;
else {
var t = JSON.stringify(e);
this.info.receivedBytedCount = t.length;
}
},
},
]),
e
);
})(),
qn = (function () {
function e(t, n) {
u(this, e),
(this.unityManager = t),
(this.monitor = n),
(this.loadCount = 0),
(this.loadedCount = 0),
(this.cacheableCount = 0),
(this.hitCacheCount = 0),
(this.loadFromCacheCount = 0),
(this.loadedSize = 0),
(this.startTime = 0),
(this.useH2 = !1),
(this.enabledH2Count = 0),
(this.checkedH2 = !1),
(this.useContentEncoding = !1),
(this.enabledContentEncodingCount = 0),
(this.needEnableContentEncodingCount = 0),
(this.checkedContentEncoding = !1);
}
return (
c(e, [
{
key: "baseReset",
value: function () {
(this.loadCount = 0),
(this.loadedCount = 0),
(this.cacheableCount = 0),
(this.hitCacheCount = 0),
(this.loadFromCacheCount = 0),
(this.loadedSize = 0),
(this.startTime = 0),
(this.needEnableContentEncodingCount = 0);
},
},
{
key: "baseLoad",
value: function () {
this.startTime || (this.startTime = Date.now()),
(this.loadCount += 1);
},
},
{
key: "completeLoad",
value: function (e, t, n, i) {
var a, r;
this.loadedCount += 1;
var o = jn.getTask(e, i);
if (!o) return !1;
var s =
(null === (a = t) || void 0 === a ? void 0 : a.status) ||
(null === (r = t) || void 0 === r ? void 0 : r.statusCode);
return (
n || s !== Nn ? o.requestFail(n) : o.requestSuccess(t, !0),
jn.removeTask(o),
!0
);
},
},
{
key: "baseCheck",
value: function (e) {
this.checkHttp2(e),
this.checkContentEncoding(e),
this.checkCache(e);
},
},
{
key: "checkHttp2",
value: function (e) {
var t;
("h2" === e.info.protocol ||
(null === (t = e.info.protocol) || void 0 === t
? void 0
: t.includes("http/2"))) &&
(this.enabledH2Count += 1);
},
},
{
key: "checkContentEncoding",
value: function (e) {
var t = !!e.info.enableContentEncoding;
t ||
!e.info.cacheable ||
e.info.isReadFromCache ||
(this.needEnableContentEncodingCount += 1),
t && (this.enabledContentEncodingCount += 1);
},
},
{
key: "checkCache",
value: function (e) {
e.info.hitCache && (this.hitCacheCount += 1),
e.info.isReadFromCache && (this.loadFromCacheCount += 1);
},
},
]),
e
);
})(),
Qn = { cpuprofile: "请使用安卓cpuprofile分析卡顿问题" },
Kn = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.apply(this, arguments)).result = {}),
(e.limit = parseInt(String(50), 10)),
e
);
}
return (
c(n, [
{
key: "init",
value: function () {
var e = fe.getConfig(F.Fps);
(this.limit = parseInt(String((1 / e) * 1e3), 10)),
(this.currentFrame = 0),
(this.wrongFrame = {});
},
},
{
key: "start",
value: function () {
this.requestID ||
((this.startTime = Date.now()),
requestAnimationFrame(this.counter.bind(this)));
},
},
{
key: "stop",
value: function () {
cancelAnimationFrame(this.requestID), (this.requestID = 0);
},
},
{
key: "reset",
value: function () {
this.stop(),
(this.startTime = 0),
(this.currentFrame = 0),
(this.currentTime = 0),
(this.wrongFrame = {}),
(Qn = null);
},
},
{
key: "showResult",
value: function () {
return (
this.stop(),
(this.result = this.getResultInfo()),
this.checkResult()
);
},
},
{
key: "getRuntime",
value: function () {
return Date.now() - this.startTime;
},
},
{
key: "getResultInfo",
value: function () {
var e = Object.keys(this.wrongFrame),
t = Object.values(this.wrongFrame),
n = Object.entries(this.wrongFrame).sort(function (e, t) {
return t[1].frameCost - e[1].frameCost;
}),
i = n[0],
a = t.reduce(function (e, t) {
return e + t.frameCost;
}, 0),
r = this.getRuntime(),
o = Ge.getRuntime(),
s = Number((a / r).toFixed(4));
return {
frames: e,
frameCount: e.length,
longestFrame: i
? {
frame: i[0],
frameCost: i[1].frameCost,
runtime: i[1].runtime,
}
: {},
topFrameCost: n.slice(0, 5).map(function (e) {
return e[1].frameCost;
}),
topFrameNetworkCount: n.slice(0, 5).map(function (e) {
return e[1].loadingCount;
}),
frameInfo: this.wrongFrame,
totalJankTime: a,
jankRate: s,
timerRuntime: r,
appRuntime: o,
configMonitorDuration: fe.getConfig(F.MonitorDuration),
showResultAfterLaunch: fe.getConfig(F.ShowResultAfterLaunch),
configFps: fe.getConfig(F.Fps),
};
},
},
{
key: "checkResult",
value: function () {
ze.monitorLog("----帧率检测 start ----"),
ze.monitorLog("帧率基本信息:", this.result);
var e = [],
t = this.result,
n = t.longestFrame;
return (
n.frameCost > 1e3 &&
e.push(
"存在长耗时帧cost="
.concat(n.frameCost, "ms,runtime=")
.concat(n.runtime, "ms")
),
+t.totalJankTime > 5e3 &&
e.push("总卡顿时长".concat(t.totalJankTime, "ms")),
+t.jankRate > 0.3 &&
e.push(
"卡顿时长占比".concat(
parseInt(String(100 * t.jankRate), 10),
"%"
)
),
e.length &&
(ze.monitorWarn("帧率优化建议:"),
e.push(Qn.cpuprofile),
ze.monitorWarn(e.join("\n"))),
ze.monitorLog("----帧率检测 end ----"),
e
);
},
},
{
key: "counter",
value: function () {
this.currentFrame += 1;
var e = Date.now(),
t = e - this.currentTime;
t > this.limit &&
(ze.monitorWarn(
"frame="
.concat(this.currentFrame, "; cost=")
.concat(t, "ms; runtime=")
.concat(this.getRuntime(), "ms")
),
(this.wrongFrame[this.currentFrame] = {
frameCost: t,
runtime: this.getRuntime(),
loadingCount: jn.loadingCount,
})),
(this.currentTime = e),
(this.requestID = requestAnimationFrame(
this.counter.bind(this)
));
},
},
]),
n
);
})(ce).getInstance(),
Xn = {
disableH2: "未开启http2",
noCDNCache: "未命中CDN缓存",
cacheBundleSettings: "请勿缓存settings.json",
noCacheCatalog: "可将catalog.json配置为可缓存文件",
noCatalogHash: "catalog.json被缓存且无hash/版本信息, 会导致无法更新",
requestCataHash: "请勿请求catalog.hash来做资源热更新,小游戏平台不支持",
lessCacheableCount: "可缓存文件过少,检查缓存配置",
lessParallelCount: "网络并发数过少",
lessNetworkTime: "网络未充分利用",
},
Zn = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.apply(this, arguments)).cacheableCount = 0),
(e.cacheableSize = 0),
(e.noCacheableAssetCount = 0),
(e.noCacheableAssetSize = 0),
(e.requestBundleSettings = !1),
(e.cacheSettings = !1),
(e.requestBundleCatalog = !1),
(e.cacheCatalog = !1),
(e.appendHashToCatalog = !1),
(e.requestCataHash = !1),
(e.result = {}),
(e.loadedTasks = []),
(e.loadedTasksMap = new Map()),
(e.cacheableRemoteCount = 0),
(e.cacaheableRemoteSize = 0),
(e.texturesCount = 0),
(e.texturesSize = 0),
e
);
}
return (
c(n, [
{
key: "startLoad",
value: function (e, t) {
var n = this;
if (!this.monitor.endMonitor) {
var i = jn.genTask(e, t);
this.baseLoad(),
(i.afterSuccess = function (e) {
var t = e.info.receivedBytedCount || 0,
i = !!e.info.cacheable,
a = !!n.loadedTasksMap.has(e.info.url);
(!i || (i && !a)) &&
(n.loadedTasks.push(e.info), (n.loadedSize += t)),
e.info.url.includes(d.DATA_CDN)
? (i
? (a ||
(n.loadedTasksMap.set(e.info.url, !0),
(n.cacheableCount += 1),
(n.cacheableSize += t)),
e.info.isReadFromCache ||
((n.cacheableRemoteCount += 1),
(n.cacaheableRemoteSize += t)))
: ((n.noCacheableAssetCount += 1),
(n.noCacheableAssetSize += t)),
e.info.isTexture &&
(a ||
(n.loadedTasksMap.set(e.info.url, !0),
(n.texturesCount += 1),
(n.texturesSize += t))),
n.baseCheck(e),
n.checkStreamingAssets(e))
: ((n.noCacheableAssetCount += 1),
(n.noCacheableAssetSize += t));
});
}
},
},
{
key: "reset",
value: function () {
this.baseReset(),
(this.cacheableCount = 0),
(this.requestBundleSettings = !1),
(this.cacheSettings = !1),
(this.requestBundleCatalog = !1),
(this.cacheCatalog = !1),
(this.appendHashToCatalog = !1),
(this.requestCataHash = !1),
(this.loadedTasks = []),
this.loadedTasksMap.clear(),
(Xn = null);
},
},
{
key: "showResult",
value: function () {
return (this.result = this.getResultInfo()), this.checkResult();
},
},
{
key: "checkResult",
value: function () {
ze.monitorLog("----网络监控 start----"),
ze.monitorLog("网络基本信息:", this.result);
var e = [],
t = this.result,
n = Gn.getPrimaryDataCachePath();
return t.loadCount
? (n || t.useH2 || e.push(Xn.disableH2),
t.needEnableContentEncodingCount &&
e.push(
"未开启服务器压缩资源个数: ".concat(
t.needEnableContentEncodingCount
)
),
t.hitCacheCount || e.push(Xn.noCDNCache),
t.requestBundleSettings &&
t.cacheSettings &&
e.push(Xn.cacheBundleSettings),
t.requestBundleCatalog &&
!t.cacheCatalog &&
e.push(Xn.noCacheCatalog),
t.requestBundleCatalog &&
t.cacheCatalog &&
!t.appendHashToCatalog &&
e.push(Xn.noCatalogHash),
t.requestCataHash && e.push(Xn.requestCataHash),
+t.cacheableCount < t.loadCount / 2 &&
e.push(Xn.lessCacheableCount),
+t.avgLoadingCount < 5 && e.push(Xn.lessParallelCount),
t.networkTime / t.duration < 0.7 &&
e.push(Xn.lessNetworkTime),
e.length &&
(ze.monitorWarn("网络优化建议:"),
ze.monitorWarn(e.join("\n"))),
ze.monitorLog("----网络监控 end----"),
e)
: (ze.monitorLog("----网络监控 end----"), e);
},
},
{
key: "getResultInfo",
value: function () {
var e = this.loadedTasks.slice().sort(function (e, t) {
return Number(t.duration) - Number(e.duration);
}),
t = e.filter(function (e) {
return !e.isReadFromCache;
}),
n = e.filter(function (e) {
return !!e.isReadFromCache;
}),
i = t.map(function (e) {
return e.pendingDuration;
}),
a = n
.map(function (e) {
return e.duration || 0;
})
.sort(function (e, t) {
return t - e;
});
return (
this.enabledH2Count && (this.useH2 = !0),
this.enabledContentEncodingCount &&
(this.useContentEncoding = !0),
{
useH2: this.useH2,
enabledH2Count: this.enabledH2Count,
enabledContentEncodingCount:
this.enabledContentEncodingCount,
useContentEncoding: this.useContentEncoding,
cacheSettings: this.cacheSettings,
cacheCatalog: this.cacheCatalog,
appendHashToCatalog: this.appendHashToCatalog,
requestCataHash: this.requestCataHash,
requestBundleSettings: this.requestBundleSettings,
requestBundleCatalog: this.requestBundleCatalog,
loadCount: this.loadCount,
loadedCount: this.loadedCount,
loadedSizeStr: "".concat(
(this.loadedSize / 1024 / 1024).toFixed(2),
"MB"
),
loadedSize: this.loadedSize,
totalSize:
this.loadedSize +
this.monitor.preloadMonitor.result.loadedSize,
hitCacheCount: this.hitCacheCount,
cacheableCount: this.cacheableCount,
loadFromCacheCount: this.loadFromCacheCount,
startTime: this.startTime,
duration: this.startTime ? Date.now() - this.startTime : 0,
networkTime: jn.totalNetworkTime,
maxLoadingCount: jn.maxLoadingCount,
avgLoadingCount: jn.avgLoadingCount,
loadedTasks: e,
cacheableSize: this.cacheableSize,
noCacheableAssetCount: this.noCacheableAssetCount,
noCacheableAssetSize: this.noCacheableAssetSize,
avgPendingDuration: i.length
? Math.round(
i.reduce(function (e, t) {
return e + t;
}, 0) / i.length
)
: 0,
topPendingDuration: i.slice(0, 5),
remoteRequestCount: t.length,
cacheableRemoteCount: this.cacheableRemoteCount,
cacaheableRemoteSize: this.cacaheableRemoteSize,
needCacheTextures: d.needCacheTextures,
texturesCount: this.texturesCount,
texturesSize: this.texturesSize,
avgReadCacheCost: a.length
? Math.round(
a.reduce(function (e, t) {
return e + t;
}, 0) / a.length
)
: 0,
topReadCacheCost: a.slice(0, 5),
topNetworkTime: t
.sort(function (e, t) {
return t.duration - e.duration;
})
.slice(0, 5)
.map(function (e) {
return e.duration;
}),
networkUsage: Number(
(jn.totalNetworkTime / Kn.getRuntime()).toFixed(4)
),
}
);
},
},
{
key: "checkStreamingAssets",
value: function (e) {
var t = e.info.url,
n = t.substring(t.lastIndexOf("/"));
!this.requestBundleSettings &&
n.includes("settings") &&
((this.requestBundleSettings = !0),
e.info.cacheable && (this.cacheSettings = !0)),
!this.requestBundleCatalog &&
n.includes("catalog") &&
((this.requestBundleCatalog = !0),
e.info.cacheable && (this.cacheCatalog = !0),
n.includes("catalog.") || (this.appendHashToCatalog = !0)),
!this.requestCataHash &&
n.includes("catalog") &&
n.endsWith("hash") &&
(this.requestCataHash = !0);
},
},
]),
n
);
})(qn),
Jn = {
noPreloadAssets: "未使用预下载能力",
tooManyAssets: "预下载资源个数较多",
tooLargeAssetSize: "预下载资源量较大",
lowDownloadSpeed:
"已发起预下载,但未完成,请检查预下载资源是否过大,或是否下载过慢",
smallAssetSize: "预下载资源较小,请将大资源调整到预下载列表顶部",
},
Yn = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.apply(this, arguments)).finished = !1),
(e.preloadInfoList = new Map()),
(e.callmainInfo = {}),
(e.result = {}),
(e.preloadListLength = 0),
e
);
}
return (
c(n, [
{ key: "init", value: function () {} },
{
key: "setPreloadList",
value: function (e) {
(this.preloadInfoList = e),
(this.preloadListLength = this.preloadInfoList.size);
},
},
{
key: "startLoad",
value: function (e) {
var t = this,
n = jn.genTask(e);
this.baseLoad(),
(n.afterSuccess = function (e) {
(t.loadedSize += e.info.receivedBytedCount || 0),
t.baseCheck(e);
});
},
},
{
key: "genResultAfterCallmain",
value: function () {
(0, _.xb)(this.callmainInfo) &&
(this.callmainInfo = this.getResultInfo());
},
},
{
key: "finishPreload",
value: function () {
this.finished ||
this.monitor.endMonitor ||
((this.finished = !0), (this.result = this.getResultInfo()));
},
},
{
key: "reset",
value: function () {
this.baseReset(),
(this.callmainInfo = {}),
(this.preloadInfoList = new Map()),
(this.finished = !1),
(Jn = null);
},
},
{
key: "showResult",
value: function () {
return (
this.genResultAfterCallmain(),
this.finishPreload(),
this.checkResult()
);
},
},
{
key: "checkResult",
value: function () {
ze.monitorLog("----预下载监控 start----"),
ze.monitorLog(
"预下载基本信息: ",
this.result,
", callmain完成时预下载信息",
this.callmainInfo
);
var e = [],
t = this.preloadListLength;
t || e.push(Jn.noPreloadAssets),
t > 15 && e.push(Jn.tooManyAssets);
var n = this.callmainInfo,
i = this.result;
return (
t &&
n &&
(n.loadingCount && !n.loadedCount
? e.push(Jn.lowDownloadSpeed)
: +n.loadedSize < 1048576 && e.push(Jn.smallAssetSize)),
t &&
i &&
(+i.loadedSize < 5242880 && e.push(Jn.smallAssetSize),
+i.loadedSize > 20971520 && e.push(Jn.tooLargeAssetSize)),
e.length &&
(ze.monitorWarn("预下载优化建议:"),
ze.monitorWarn(e.join("\n"))),
ze.monitorLog("----预下载监控 end----"),
e
);
},
},
{
key: "getResultInfo",
value: function () {
return {
loadedCount: this.loadedCount,
loadingCount: this.loadCount - this.loadedCount,
loadedSizeStr: "".concat(
(this.loadedSize / 1024 / 1024).toFixed(2),
"MB"
),
loadedSize: this.loadedSize,
hitCacheCount: this.hitCacheCount,
useH2: this.useH2,
useContentEncoding: this.useContentEncoding,
preloadListLength: this.preloadListLength,
};
},
},
]),
n
);
})(qn),
$n = {
loadDurationCallmain:
"wasm子包在callmain期间加载,请使用分包工具继续收集",
loadSubwasmEarly: "wasm子包加载时机过早,请使用分包工具继续收集",
longFetchPending: "缺失函数过多,请使用分包工具继续收集",
},
ei = (function () {
function e(t, n) {
u(this, e),
(this.unityManager = t),
(this.monitor = n),
(this.loadSubWasmPackageStartTime = 0),
(this.loadSubWasmPackageCostTime = 0),
(this.timeAfterCallmain = 0),
(this.loadDurationCallmain = !1),
(this.maxFetchPendingTime = 0),
(this.result = {}),
(this.isFetching = !1);
}
return (
c(e, [
{ key: "init", value: function () {} },
{
key: "startLoadSubWasm",
value: function () {
if (
((this.loadSubWasmPackageStartTime = Date.now()),
this.unityManager.mainCalled)
) {
var e = Ge.getRuntime(),
t = this.unityManager.launchData.find(function (e) {
return e.type === Te.PREPARE_GAME;
});
if (t) {
var n = e - t.data.runTimeMs;
this.timeAfterCallmain = n;
}
} else this.loadDurationCallmain = !0;
},
},
{
key: "finishLoadSubWasm",
value: function () {
this.loadSubWasmPackageCostTime =
Date.now() - this.loadSubWasmPackageStartTime;
},
},
{
key: "recordSyncFetchTime",
value: function () {
var e = this;
if (!this.isFetching && !this.monitor.endMonitor) {
this.isFetching = !0;
var t = Date.now();
this.loadSubWasmPackageStartTime ||
((this.loadSubWasmPackageStartTime = t),
this.startLoadSubWasm()),
setTimeout(function () {
if (!e.monitor.enableMonitor) {
var n = Date.now() - t;
n > e.maxFetchPendingTime &&
(e.maxFetchPendingTime = n),
n > 500 && ze.monitorWarn("fetchjs等待耗时: ", n),
(e.isFetching = !1);
}
}, 0);
}
},
},
{
key: "reset",
value: function () {
(this.loadSubWasmPackageStartTime = 0),
(this.loadSubWasmPackageCostTime = 0),
(this.timeAfterCallmain = 0),
(this.loadDurationCallmain = !1),
(this.maxFetchPendingTime = 0),
(this.result = {}),
($n = null);
},
},
{
key: "showResult",
value: function () {
return (this.result = this.getResultInfo()), this.checkResult();
},
},
{
key: "checkResult",
value: function () {
ze.monitorLog("----wasm分包监控 start----"),
ze.monitorLog("wasm分包基本信息: ", this.result);
var e = this.result,
t = [];
return (
e.loadDurationCallmain && t.push($n.loadDurationCallmain),
e.costTimeAfterCallmain &&
+e.costTimeAfterCallmain < 3e4 &&
t.push($n.loadSubwasmEarly),
+e.maxFetchPendingTime > 2e3 && t.push($n.longFetchPending),
t.length &&
(ze.monitorWarn("wasm分包优化建议:"),
ze.monitorWarn(t.join("\n"))),
ze.monitorLog("----wasm分包监控 end----"),
t
);
},
},
{
key: "getResultInfo",
value: function () {
return {
loadSubWasmPackageStartTime: this.loadSubWasmPackageStartTime,
loadSubWasmPackageCostTime: this.loadSubWasmPackageCostTime,
loadDurationCallmain: this.loadDurationCallmain,
maxFetchPendingTime: this.maxFetchPendingTime,
costTimeAfterCallmain: this.timeAfterCallmain,
};
},
},
]),
e
);
})(),
ti = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.apply(this, arguments)).enableMonitor = fe.getConfig(
F.EnableMonitor
)),
(e.endMonitor = !1),
(e.reportData = {}),
(e.isGameInteractive = !1),
e
);
}
return (
c(n, [
{
key: "init",
value: function (e) {
this.enableMonitor
? (ze.pluginWarn(
"[仅开发版/体验版生效]已开启最佳实践检测, 请前往github查阅说明文档:\nhttps://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/PerformanceMonitor.md"
),
(this.unityManager = e),
(this.commonMonitor = new zn(e, this)),
(this.requestMonitor = new Zn(e, this)),
(this.preloadMonitor = new Yn(e, this)),
(this.wasmSplitMonitor = new ei(e, this)),
Kn.init())
: ((this.commonMonitor = {
recordAsset: function () {},
recordWasm: function () {},
recordCallmain: function () {},
showResult: function () {},
}),
(this.requestMonitor = {
startLoad: function () {},
completeLoad: function () {},
showResult: function () {},
}),
(this.preloadMonitor = {
setPreloadList: function () {},
finishPreload: function () {},
startLoad: function () {},
completeLoad: function () {},
genResultAfterCallmain: function () {},
showResult: function () {},
}),
(this.wasmSplitMonitor = {
recordSyncFetchTime: function () {},
startLoadSubWasm: function () {},
finishLoadSubWasm: function () {},
showResult: function () {},
}));
},
},
{
key: "showResultAfterDuration",
value: function () {
var e = this;
if (!this.endMonitor && this.enableMonitor) {
Kn.start();
var t = fe.getConfig(F.ShowResultAfterLaunch)
? 6e4
: fe.getConfig(F.MonitorDuration);
setTimeout(function () {
e.showResult();
}, t);
}
},
},
{
key: "showResult",
value: function () {
var e =
arguments.length > 0 &&
void 0 !== arguments[0] &&
arguments[0];
if (this.enableMonitor && !this.endMonitor) {
this.isGameInteractive = e;
var t = this.commonMonitor.showResult(),
n = this.preloadMonitor.showResult(),
i = this.wasmSplitMonitor.showResult(),
a = this.requestMonitor.showResult(),
r = Kn.showResult(),
o = "";
t.length &&
((o += "===启动优化建议: ===\n"),
(o += "".concat(t.join("\n"), "\n"))),
n.length &&
((o += "===预下载优化建议: ===\n"),
(o += "".concat(n.join("\n"), "\n"))),
i.length &&
((o += "===wasm分包优化建议: ===\n"),
(o += "".concat(i.join("\n"), "\n"))),
a.length &&
((o += "===网络优化建议: ===\n"),
(o += "".concat(a.join("\n"), "\n"))),
r.length &&
((o += "===帧率优化建议: ===\n"),
(o += "".concat(r.join("\n"), "\n"))),
o &&
fe.getConfig(F.ShowSuggestModal) &&
((o = "<打开调试查看功能文档>\n".concat(o)),
h.showModal({
title: "优化建议" + (e ? "[可交互]" : ""),
content: o,
})),
this.reportInfo(),
this.showResultInfo(),
(e && !fe.getConfig(F.ShowResultAfterLaunch)) || this.end(),
(this.isGameInteractive = !1);
}
},
},
{
key: "end",
value: function () {
!this.endMonitor &&
this.enableMonitor &&
(this.commonMonitor.reset(),
this.preloadMonitor.reset(),
this.wasmSplitMonitor.reset(),
this.requestMonitor.reset(),
Kn.reset(),
(this.reportData = {}),
(this.endMonitor = !0));
},
},
{
key: "reportInfo",
value: function () {
this.reportBaseInfo(),
this.reportAssetInfo(),
this.reportFrameInfo();
},
},
{
key: "showResultInfo",
value: function () {
var e = this.showBaseInfo(),
t = this.showAssetInfo(),
n = this.showFrameInfo(),
i = [].concat(e, t, n).join("\n");
ze.monitorWarn(
"[monitor-report]",
"检测报告".concat(
this.isGameInteractive ? "[可交互]" : "",
": "
),
i
),
fe.getConfig(F.ShowReportModal) &&
h.showModal({
title:
"检测报告" + (this.isGameInteractive ? "[可交互]" : ""),
content: i,
showCancel: !1,
success: function () {
h.setClipboardData({ data: i });
},
});
},
},
{
key: "showBaseInfo",
value: function () {
var e = this.reportData.baseInfo,
t = e.downloadWasm,
n = e.wasmContentLength,
i = e.downloadDataPackage,
a = e.assetContentLength,
r = e.useContentEncoding,
o = e.callmain,
s = e.preloadListLength,
u = e.preloadCount,
c = e.preloadSize,
l = e.preloadCountAfterCallmain,
h = e.preloadSizeAfterCallmain,
d = e.launchTime,
f = [];
return (
f.push("wasm下载耗时: ".concat(t, "ms")),
f.push(
"wasm包大小: ".concat((n / 1024 / 1024).toFixed(2), "MB")
),
f.push("资源包下载耗时: ".concat(i || 0, "ms")),
f.push(
"资源包大小: ".concat((a / 1024 / 1024).toFixed(2), "MB")
),
f.push("资源包是否压缩: ".concat(!!r)),
f.push("引擎初始化耗时: ".concat(o, "ms")),
f.push("引擎初始化完成耗时: ".concat(d, "ms")),
f.push("预下载配置个数: ".concat(s)),
f.push("总预下载完成个数: ".concat(u)),
f.push(
"总预下载完成大小: ".concat(
(c / 1024 / 1024).toFixed(2),
"MB"
)
),
f.push("引擎初始化完成时预载个数: ".concat(l)),
f.push(
"引擎初始化完成时预载大小: ".concat(
(h / 1024 / 1024).toFixed(2),
"MB"
)
),
f
);
},
},
{
key: "showAssetInfo",
value: function () {
var e = this.reportData.assetInfo,
t = e.useH2,
n = e.enabledH2Count,
i = e.enabledContentEncodingCount,
a = e.useContentEncoding,
r = e.cacheSettings,
o = e.cacheCatalog,
s = e.appendHashToCatalog,
u = e.requestCataHash,
c = e.requestBundleSettings,
l = e.requestBundleCatalog,
h = e.loadCount,
d = e.loadedSize,
f = e.totalSize,
g = e.cacheableCount,
p = e.hitCacheCount,
m = e.duration,
v = e.networkTime,
y = e.networkUsage,
S = e.maxLoadingCount,
T = e.cacheableSize,
b = e.avgLoadingCount,
w = e.texturesCount,
C = e.texturesSize,
E = e.needCacheTextures,
k = e.cacaheableRemoteSize,
I = e.cacheableRemoteCount,
P = e.avgPendingDuration,
R = e.topPendingDuration,
A = e.avgReadCacheCost,
L = e.topReadCacheCost,
D = e.topNetworkTime,
M = e.remoteRequestCount,
x = e.noCacheableAssetCount,
F = e.noCacheableAssetSize,
_ = [];
return (
_.push("网络时长: ".concat(v, "ms")),
_.push("网络时长占比: ".concat((100 * y).toFixed(1), "%")),
_.push("距首个网络请求开始时长: ".concat(m, "ms")),
_.push("总请求个数(含命中本地缓存): ".concat(h)),
_.push("实际网络请求个数(未命中本地缓存): ".concat(M)),
_.push("自动缓存资源个数: ".concat(g)),
_.push("未自动缓存资源个数: ".concat(x)),
_.push("自动缓存资源网络个数: ".concat(I)),
_.push("纹理个数: ".concat(w)),
_.push(
"总资源大小(含预载): ".concat(
(f / 1024 / 1024).toFixed(2),
"MB"
)
),
_.push(
"总资源大小(不含预载): ".concat(
(d / 1024 / 1024).toFixed(2),
"MB"
)
),
_.push(
"自动缓存资源大小: ".concat(
(T / 1024 / 1024).toFixed(2),
"MB"
)
),
_.push(
"未自动缓存资源大小: ".concat(
(F / 1024 / 1024).toFixed(2),
"MB"
)
),
_.push(
"自动缓存资源网络大小: ".concat(
(k / 1024 / 1024).toFixed(2),
"MB"
)
),
_.push(
"纹理大小: ".concat((C / 1024 / 1024).toFixed(2), "MB")
),
_.push("是否缓存纹理: ".concat(E)),
_.push("平均并发数: ".concat(b)),
_.push("最大并发数: ".concat(S)),
_.push("平均请求阻塞时长: ".concat(P, "ms")),
_.push("TOP5请求阻塞时长: [".concat(R.toString(), "]")),
_.push("平均读缓存耗时: ".concat(A, "ms")),
_.push("TOP5读缓存耗时: [".concat(L.toString(), "]")),
_.push("TOP5网络耗时: [".concat(D.toString(), "]")),
_.push("命中CDN缓存数: ".concat(p)),
_.push("启用HTTP2.0个数: ".concat(n)),
_.push("是否开启HTTP2.0: ".concat(!!t)),
_.push("资源开启服务器压缩个数: ".concat(i)),
_.push("资源是否开启服务器压缩: ".concat(!!a)),
_.push("是否请求catalog: ".concat(!!l)),
_.push("catalog是否带版本信息: ".concat(!!s)),
_.push("是否请求catalog.hash热更: ".concat(!!u)),
_.push("是否缓存catalog: ".concat(!!o)),
_.push("是否请求settings: ".concat(!!c)),
_.push("是否缓存settings: ".concat(!!r)),
_
);
},
},
{
key: "showFrameInfo",
value: function () {
var e = this.reportData.frameInfo,
t = [],
n = e.frameCount,
i = e.longestFrame,
a = e.totalJankTime,
r = e.jankRate,
o = e.topFrameCost,
s = e.topFrameNetworkCount,
u = e.configMonitorDuration,
c = e.showResultAfterLaunch,
l = e.configFps,
h = e.timerRuntime,
d = e.appRuntime;
return (
t.push("长耗时帧个数: ".concat(n)),
t.push("最长帧耗时: ".concat(i.frameCost || 0, "ms")),
t.push("TOP5帧耗时: [".concat(o.toString(), "]")),
t.push("TOP5帧网络并发: [".concat(s.toString(), "]")),
t.push("总卡顿时长: ".concat(a, "ms")),
t.push("卡顿率: ".concat((100 * r).toFixed(1), "%")),
t.push("设置监控FPS: ".concat(l, "FPS")),
t.push("设置监控时长: ".concat(u, "ms")),
t.push("可交互结束监控: ".concat(!!c)),
t.push("实际监控时长: ".concat(h, "ms")),
t.push("运行时长: ".concat(d, "ms")),
t
);
},
},
{
key: "reportBaseInfo",
value: function () {
if (this.enableMonitor) {
var e = this.commonMonitor.result,
t = this.preloadMonitor.result,
n = this.preloadMonitor.callmainInfo,
i = e.launchTime,
a = e.wasmContentLength,
r = e.assetContentLength,
o = e.useContentEncoding,
s = t.preloadListLength,
u = t.loadedCount,
c = t.loadedSize,
l = t.useH2,
h = t.useContentEncoding,
d = n.loadedCount,
f = n.loadedSize,
g = Object.create(null),
p = {
0: "pluginLaunch",
1: "downloadWasm",
2: "compileWasm",
3: "downloadDataPackage",
5: "readDataPackage",
6: "callmain",
};
this.unityManager.launchData.forEach(function (e) {
p[e.type] && (g[p[e.type]] = e.data.costTimeMs);
}),
Object.assign(g, {
launchTime: i,
wasmContentLength: a,
assetContentLength: r,
useContentEncoding: o,
preloadListLength: s,
preloadCount: u,
preloadSize: c,
useH2: l,
preloadUseContentEncoding: h,
preloadCountAfterCallmain: d,
preloadSizeAfterCallmain: f,
isGameInteractive: this.isGameInteractive,
}),
(this.reportData.baseInfo = g),
Pt.send(
new kt({
ReportType: Ce.BASE_INFO,
ExternInfo: JSON.stringify(g),
})
);
}
},
},
{
key: "reportAssetInfo",
value: function () {
if (this.enableMonitor) {
var e = this.requestMonitor.result,
t = e.useH2,
n = e.enabledH2Count,
i = e.enabledContentEncodingCount,
a = e.useContentEncoding,
r = e.cacheSettings,
o = e.cacheCatalog,
s = e.appendHashToCatalog,
u = e.requestCataHash,
c = e.requestBundleSettings,
l = e.requestBundleCatalog,
h = e.loadCount,
d = e.loadedCount,
f = e.loadedSize,
g = e.cacheableSize,
p = e.cacheableCount,
m = e.hitCacheCount,
v = e.duration,
y = e.networkTime,
S = e.networkUsage,
T = e.maxLoadingCount,
b = e.avgLoadingCount,
w = e.totalSize,
C = e.noCacheableAssetCount,
E = e.noCacheableAssetSize,
k = e.remoteContentSize,
I = e.avgPendingDuration,
P = e.topPendingDuration,
R = e.remoteRequestCount,
A = e.cacheableRemoteCount,
L = e.cacaheableRemoteSize,
D = e.needCacheTextures,
M = e.texturesCount,
x = e.texturesSize,
F = e.avgReadCacheCost,
_ = e.topReadCacheCost,
O = e.topNetworkTime,
N = e.monitorDuration,
W = e.showResultAfterLaunch,
U = Object.create(null);
Object.assign(U, {
useH2: t,
enabledH2Count: n,
enabledContentEncodingCount: i,
useContentEncoding: a,
cacheSettings: r,
cacheCatalog: o,
appendHashToCatalog: s,
requestCataHash: u,
requestBundleSettings: c,
requestBundleCatalog: l,
loadCount: h,
loadedCount: d,
loadedSize: f,
totalSize: w,
cacheableCount: p,
hitCacheCount: m,
duration: v,
networkTime: y,
networkUsage: S,
maxLoadingCount: T,
cacheableSize: g,
avgLoadingCount: b,
texturesCount: M,
texturesSize: x,
needCacheTextures: D,
cacaheableRemoteSize: L,
cacheableRemoteCount: A,
avgPendingDuration: I,
topPendingDuration: P,
avgReadCacheCost: F,
topReadCacheCost: _,
topNetworkTime: O,
monitorDuration: N,
showResultAfterLaunch: W,
remoteRequestCount: R,
remoteContentSize: k,
noCacheableAssetCount: C,
noCacheableAssetSize: E,
isGameInteractive: this.isGameInteractive,
}),
(this.reportData.assetInfo = U),
Pt.send(
new kt({
ReportType: Ce.ASSETS_INFO,
ExternInfo: JSON.stringify(U),
})
);
}
},
},
{
key: "reportFrameInfo",
value: function () {
if (this.enableMonitor) {
var e = Kn.result,
t = e.frameCount,
n = e.frames,
i = e.longestFrame,
a = e.totalJankTime,
r = e.jankRate,
o = e.topFrameCost,
s = e.topFrameNetworkCount,
u = e.timerRuntime,
c = e.appRuntime,
l = e.configMonitorDuration,
h = e.showResultAfterLaunch,
d = e.configFps,
f = Object.create(null);
Object.assign(f, {
frameCount: t,
longestFrame: i,
totalJankTime: a,
jankRate: r,
timerRuntime: u,
appRuntime: c,
frames: n,
topFrameCost: o,
topFrameNetworkCount: s,
configMonitorDuration: l,
showResultAfterLaunch: h,
configFps: d,
isGameInteractive: this.isGameInteractive,
}),
(this.reportData.frameInfo = f),
Pt.send(
new kt({
ReportType: Ce.FRAME_INFO,
ExternInfo: JSON.stringify(f),
})
);
}
},
},
]),
n
);
})(ce).getInstance();
(p.id = ""),
(p.style.width = V),
(p.style.height = G),
(p.width = V * U),
(p.height = G * U),
(p.widthNative = 0),
(p.heightNative = 0),
(d.eventLog = function () {
for (var e, t = arguments.length, n = new Array(t), i = 0; i < t; i++)
n[i] = arguments[i];
var a = n[0],
r = void 0 === a ? "" : a;
se.log.apply(se, ["[PLUGIN LOG] "].concat(n)),
r.includes("fetch js:") &&
n.length > 1 &&
ti.wasmSplitMonitor.recordSyncFetchTime(),
ee && (e = console).log.apply(e, ["[PLUGIN LOG]"].concat(n));
}),
(d.timeLog = function () {
for (var e, t = arguments.length, n = new Array(t), i = 0; i < t; i++)
n[i] = arguments[i];
se.log.apply(se, ["[PLUGIN TIME LOG] "].concat(n)),
(e = console).log.apply(e, ["[PLUGIN TIME LOG] "].concat(n));
});
var ni = (function () {
function e(t) {
u(this, e),
(this.loadingPageType = le.LONG_VIDEO),
(this.inited = !1),
(this.visible = !1),
(this.playing = !1),
(this.loadingVideo = null),
this.inited || this.init(t);
}
return (
c(e, [
{
key: "showLoadingPage",
value: function () {
var e = this;
return new Promise(function (t) {
e.loadingVideo && !e.visible
? ((e.visible = !0),
(e.loadingVideo.width = V),
(e.loadingVideo.height = G),
(e.loadingVideo.x = 0),
(e.loadingVideo.y = 0),
e.loadingVideo.play(),
e.loadingVideo.onplay(function () {
e.playing = !0;
}),
t())
: t();
});
},
},
{
key: "hideLoadingPage",
value: function () {
this.loadingVideo &&
this.visible &&
((this.playing = !1),
(this.visible = !1),
this.loadingVideo.pause(),
this.loadingVideo.destroy(),
(this.loadingVideo = null));
},
},
{
key: "init",
value: function (e) {
(this.inited = !0),
e.src &&
(this.loadingVideo = h.createVideo({
width: 1,
height: 1,
x: -1,
y: -1,
src: e.src,
controls: !1,
showProgress: !1,
showProgressInControlMode: !1,
autoplay: !1,
loop: !0,
enableProgressGesture: !1,
showCenterPlayBtn: !1,
underGameView: !0,
objectFit: "cover",
}));
},
},
]),
e
);
})(),
ii = (function () {
function e() {
var t = this;
u(this, e),
(this.loadedSize = 0),
(this.inited = !1),
(this.localLoadingCount = 0),
(this.defaultMaxParallelCount = 10),
(this.timer = 0),
(this.maxCount = this.defaultMaxParallelCount),
(this.preloadList = []),
(this.preloadInfoList = new Map()),
(this.loadedUrls = new Map()),
(this.httpTaskManager = null),
(this.setPreloadList = function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: [];
if (null == e ? void 0 : e.length) {
e.filter(function (e) {
return !!(null == e ? void 0 : e.trim());
})
.map(t.handlePreloadInfo)
.forEach(function (e) {
un(e.url) && t.preloadInfoList.set(e.shortSubPath, e);
});
var n = ua.getInstance(),
i =
!t.preloadList.length &&
!!n &&
!(null == n ? void 0 : n.isAssetsLoading);
(t.preloadList = Array.from(t.preloadInfoList.values()).map(
function (e) {
return e.url;
}
)),
t.inited && i && t.load(),
ti.preloadMonitor.setPreloadList(t.preloadInfoList);
}
}),
(this.handlePreloadInfo = function (e) {
var t = e.includes("http") ? e : Yt(ln("StreamingAssets"), e),
n = en((t = $t(t))),
i = nn(t),
a = on(t),
r = rn(t);
return {
url: t,
md5: a,
shortFilename: r,
filename: n,
subPath: Yt(i, n),
shortSubPath: Yt(i, r),
};
}),
(this.releaseAll = function () {
Array.from(t.loadedUrls.keys()).forEach(function (e) {
t.releaseTask(new Wn(e));
}),
(t.timer = 0);
}),
(this.load = function () {
return (function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
})(
t,
void 0,
void 0,
n().mark(function e() {
var t, i, a, r, o, u, c, l, h, d, f, g, p;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if ((i = this.preloadList.shift())) {
e.next = 3;
break;
}
return e.abrupt("return");
case 3:
if (
((a = this.handlePreloadInfo(i)),
(r = new Wn(i)),
!this.getTaskByUrl(i))
) {
e.next = 6;
break;
}
return e.abrupt("return");
case 6:
if (!wn.getCachePath(i)) {
e.next = 8;
break;
}
return e.abrupt(
"return",
void setTimeout(this.load, 0)
);
case 8:
return (
(o = en(i)),
(e.prev = 9),
ti.preloadMonitor.startLoad(i),
this.addTask(r),
Ge.timeStart("preload:".concat(i)),
ze.pluginLog(
"PreloadManager: ".concat(o, "开始预载")
),
(e.next = 13),
$e(wn.downloadFileByXMLHttpRequest(i))
);
case 13:
if (
((u = e.sent),
(c = s(u, 2)),
(l = c[0]),
(h = c[1]),
(d =
this.preloadInfoList.has(a.shortSubPath) &&
(null ===
(t = this.preloadInfoList.get(
a.shortSubPath
)) || void 0 === t
? void 0
: t.subPath) !== a.subPath) ||
ti.preloadMonitor.completeLoad(i, h, l),
(d || l) && Ge.timeEnd("preload:".concat(i)),
!d)
) {
e.next = 20;
break;
}
return e.abrupt(
"return",
((r.statusCode = 400), this.removeTask(r))
);
case 20:
if (!l) {
e.next = 22;
break;
}
throw (
(r.statusCode || (r.statusCode = 400),
(r.error = l),
l)
);
case 22:
this.loadedUrls.set(i, !0),
this.checkNeedReleaseAll(),
(f = h.response),
(g = h.status),
(r.statusCode = g),
g === Nn
? (ze.pluginLog(
"PreloadManager: "
.concat(o, "预载完成, 耗时: ")
.concat(
Ge.timeEnd("preload:".concat(i)),
"ms"
)
),
(p = f.byteLength),
this.countLoadedFileSize(p),
(r.response = f),
Ge.timeStart("savepreload:".concat(i)),
$e(wn.writeFile(Yt(nn(i), o), f)).then(
function (e) {
var t = s(e, 1)[0];
ze.pluginLog(
"PreloadManager: "
.concat(i, "缓存完成,耗时: ")
.concat(
Ge.timeEnd(
"savepreload:".concat(i)
),
"ms"
)
),
t &&
ze.pluginError(
"PreloadManager: ".concat(
o,
"未正常缓存"
),
t.errMsg || t.message,
t
);
}
))
: this.reportHttpError({
filename: o,
url: i,
error: g,
type: "onerror",
}),
(e.next = 30);
break;
case 27:
(e.prev = 27),
(e.t0 = e.catch(9)),
this.reportHttpError({
filename: o,
url: i,
error: e.t0,
type: "catch",
});
case 30:
this.removeTask(r, !1);
case 31:
case "end":
return e.stop();
}
},
e,
this,
[[9, 27]]
);
})
);
});
}
return (
c(
e,
[
{
key: "loadingCount",
get: function () {
return this.localLoadingCount;
},
set: function (e) {
Number.isInteger(e) &&
e >= 0 &&
(e < this.maxCount && setTimeout(this.load, 0),
(this.localLoadingCount = e));
},
},
{
key: "isPreloadedUrl",
value: function (e) {
return this.loadedUrls.has(e);
},
},
{
key: "init",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: { preloadList: [] },
t = e.preloadList;
this.inited ||
(this.setPreloadList(t),
(this.inited = !0),
(this.loadedSize = 0),
(this.localLoadingCount = 0),
(this.httpTaskManager = new Un()));
},
},
{
key: "hasTask",
value: function (e) {
return (
!!this.httpTaskManager && this.httpTaskManager.hasTask(e)
);
},
},
{
key: "getTaskByUrl",
value: function (e) {
return this.httpTaskManager
? this.httpTaskManager.getTaskByUrl(e)
: null;
},
},
{
key: "addTask",
value: function (e) {
this.httpTaskManager &&
(this.httpTaskManager.hasTask(e) ||
(this.httpTaskManager.addTask(e),
(this.loadingCount += 1)));
},
},
{
key: "removeTask",
value: function (e) {
var t =
!(arguments.length > 1 && void 0 !== arguments[1]) ||
arguments[1];
if (this.httpTaskManager && this.httpTaskManager.hasTask(e)) {
e.emit(Mn.COMPLETE),
(this.loadingCount -= 1),
0 === this.loadingCount &&
ti.preloadMonitor.finishPreload();
var n = this.handlePreloadInfo(e.url);
this.preloadInfoList.delete(n.shortSubPath),
t && this.releaseTask(e);
}
},
},
{
key: "handleRemove",
value: function (e) {
var t, n;
(null ===
(n =
null ===
(t = null == this ? void 0 : this.httpTaskManager) ||
void 0 === t
? void 0
: t.hasTask) || void 0 === n
? void 0
: n.call(t, e)) && this.httpTaskManager.removeTask(e);
},
},
{
key: "releaseTask",
value: function (e) {
this.handleRemove(e), this.loadedUrls.delete(e.url);
},
},
{
key: "checkNeedReleaseAll",
value: function () {
this.timer || (this.timer = setTimeout(this.releaseAll, 6e4));
},
},
{
key: "setConcurrent",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 1,
t = Number(e) || 1;
(t = t > 10 ? 10 : Math.max(1, t)), (this.maxCount = t);
},
},
{
key: "unShift",
value: function (e) {
this.preloadList.unshift(e),
(this.loadingCount = Number(this.loadingCount));
},
},
{
key: "countLoadedFileSize",
value: function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0;
return (this.loadedSize += e), this.loadedSize;
},
},
{
key: "reportHttpError",
value: function (e) {
var t = e.filename,
n = e.url,
i = e.error,
a = e.type,
r = "number" == typeof i,
o = i;
r ||
"string" == typeof i ||
(o =
(null == i ? void 0 : i.errMsg) ||
(null == i ? void 0 : i.message) ||
"empty errMsg"),
ze.pluginError(
"PreloadManager_".concat(a, ": ").concat(t, "预载失败"),
"; networkType: ",
yt.networkType,
"; isVisible: ",
dt(),
", error=",
o
),
ua.getInstance().needPluginReport() &&
Rt.send(
new kt({
ReportType: Te.LOAD_ASSET_BUNDLE,
ErrorMsg: o,
ErrorType: r ? o : 0,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
event: "PreloadManager: ".concat(a),
url: n,
gameStage: mt(),
}),
})
);
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})();
ii.instance = null;
var ai,
ri = ii.getInstance(),
oi = c(function e(t) {
u(this, e);
var n = t.getAllResponseHeaders(),
i = new Map();
n
.trim()
.split(/[\r\n]+/)
.forEach(function (e) {
var t = e.split(": "),
n = t.shift(),
a = t.join(": ");
i.set(n, a);
}),
(this.headers = i),
(this.url = t.paramsCache.url),
(this.ok = !!(t.status >= 200 && t.status < 300)),
(this.status = t.status),
(this.statusText = t.statusText),
(this.parsedBody = new Uint8Array(t.response)),
(this.originXHR = t);
}),
si = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
};
!(function (e) {
(e[(e.Fail = 0)] = "Fail"), (e[(e.Ok = 1)] = "Ok");
})(ai || (ai = {}));
var ui = c(function e(t) {
u(this, e),
(this.status = t.status),
(this.errMsg = t.errMsg),
(this.cachePath = t.xhrObj.cachePath),
(this.response = t.xhrObj.response),
(this.cacheable = t.xhrObj.cacheable),
(this.isReadFromCache = t.xhrObj.isReadFromCache);
}),
ci = (function () {
function e() {
var t = this;
u(this, e),
(this.status = void 0),
(this.statusText = void 0),
(this.cacheable = !1),
(this.isReadFromCache = !1),
(this.isFetchApi = !1),
(this.signal = { aborted: !1 }),
(this.openAndSend = function (e, n) {
return (
(t.isFetchApi = !0),
t.open(n.method, e, !0),
(t.responseType = "arraybuffer"),
Object.keys(n.headers).forEach(function (e) {
t.setRequestHeader(e, n.headers[e]);
}),
(t.timeout = n.timeout),
(t.onprogress = n.onProgress),
new Promise(function (e, i) {
(t.onFetchResolve = function () {
e(new oi(t));
}),
(t.onFetchReject = function (e) {
var n = new oi(t);
(n.message =
(null == e ? void 0 : e.errMsg) ||
(null == e ? void 0 : e.message) ||
""),
i(n);
}),
t.send(n.body);
})
);
}),
(this.send = function () {
for (
var e = arguments.length, i = new Array(e), a = 0;
a < e;
a++
)
i[a] = arguments[a];
return si(
t,
void 0,
void 0,
n().mark(function e() {
var t, a, r, o, u, c, l, h, d, f, g, p, m, v, y;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (!dn((a = this.paramsCache.url))) {
e.next = 3;
break;
}
return e.abrupt(
"return",
(Z &&
ze.debugLog(
"[开发阶段提示]请求无效URL=",
a,
", 浏览器搜索 `Disable Editor analytics` 或忽略此日志"
),
this.triggerEvent("error"))
);
case 3:
if (
((r = wn.getCachePath(a)),
(o = null),
(u = Nn),
(c = en(a)),
!un(a))
) {
e.next = 35;
break;
}
if (
(Ge.timeStart("xhr_send:".concat(a)),
!(l = ri.getTaskByUrl(a)))
) {
e.next = 22;
break;
}
if (!ri.isPreloadedUrl(a)) {
e.next = 13;
break;
}
ze.pluginLog("xhr: ".concat(c, "使用预载内容")),
(o = l.response),
(r = ""),
ri.releaseTask(new Wn(a)),
(e.next = 20);
break;
case 13:
return (
ze.pluginLog("xhr: ".concat(c, "等待预载完成")),
(e.next = 16),
l.once(Mn.COMPLETE)
);
case 16:
(h = e.sent),
(d = h.statusCode),
(f = h.response),
(u = d),
(o = f);
case 20:
e.next = 23;
break;
case 22:
ri.addTask(new Wn(a));
case 23:
if (!r) {
e.next = 31;
break;
}
return (e.next = 26), $e(wn.readFile(r));
case 26:
(g = e.sent),
(p = s(g, 2)),
(m = p[0]),
(v = p[1]),
m
? (ze.pluginError(
"xhr: ".concat(c, "读缓存失败, err="),
m.errMsg
),
Rt.send(
new kt({
ReportType: Te.LOAD_ASSET_BUNDLE,
ErrorMsg: m.errMsg,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
stage:
"CacheXMLHttpRequest: read cacheFile error",
filename: c,
gameStage: mt(),
}),
})
),
wn.removeFile(r))
: (null == v ? void 0 : v.byteLength)
? ((o = v), (u = Nn))
: (ze.pluginError(
"xhr: ".concat(c, "清理空文件缓存")
),
wn.removeFile(r));
case 31:
if (((this.cachePath = r), !o)) {
e.next = 35;
break;
}
return (
(this.isReadFromCache = !0),
this.createResponse({ data: o, statusCode: u }),
this.triggerEvent(u === Nn ? "load" : "error"),
(y = ri.getTaskByUrl(a)),
e.abrupt(
"return",
void (
y &&
((y.statusCode = u),
(y.response = o),
ri.removeTask(y))
)
)
);
case 35:
return e.abrupt(
"return",
(t = this.originXhr).send.apply(t, i)
);
case 36:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(this.open = function (e, n, i) {
var a,
r = $t(n);
if (((t.paramsCache = { method: e, url: r, async: i }), !sn(r)))
return (
ze.pluginError("URL不合法: ", r), t.triggerEvent("error")
);
for (
var o = arguments.length,
s = new Array(o > 3 ? o - 3 : 0),
u = 3;
u < o;
u++
)
s[u - 3] = arguments[u];
un(r) ? (t.cacheable = !0) : ri.addTask(new Wn(r)),
ti.requestMonitor.startLoad(r, t.reqId),
(a = t.originXhr).open.apply(a, [e, r, i].concat(s)),
(t.onload = function () {}),
(t.onerror = function () {}),
(t.ontimeout = function () {}),
(t.onabort = function () {});
}),
(this.bindEvent = function () {
var e = [
"readyState",
"response",
"responseText",
"responseURL",
"responseXML",
"status",
"statusText",
];
[
"readyState",
"response",
"responseText",
"responseType",
"responseURL",
"responseXML",
"status",
"statusText",
"timeout",
"upload",
"withCredentials",
"onloadstart",
"onprogress",
"onabort",
"onerror",
"onload",
"ontimeout",
"onloadend",
"onreadystatechange",
].forEach(function (n) {
Object.defineProperty(t, n, {
get: function () {
return (
(e.includes(n) && t["_".concat(n)]) || t.originXhr[n]
);
},
set: function (i) {
"onload" === n
? (t.originXhr[n] = function (e) {
t.isFetchApi ? t.triggerEvent("FetchResolve") : i(e),
t.handleTaskComplete();
var n = t.paramsCache.url;
if (
(ti.requestMonitor.completeLoad(
n,
t,
void 0,
t.reqId
),
t.cacheable)
) {
var a = wn.getFileInfo(n),
r = en(n);
if (t.status === Nn) {
if (!t.response.byteLength)
return (
t.triggerEvent(
"complete",
new ui({
xhrObj: t,
status: ai.Fail,
errMsg: "empty content",
})
),
ze.pluginError(
"xhr_onload: ".concat(
r,
"是空文件,不使用缓存"
)
)
);
if (a)
t.triggerEvent(
"complete",
new ui({ xhrObj: t, status: ai.Ok })
),
ze.pluginLog(
"xhr_onload: "
.concat(r, ",耗时=")
.concat(
Ge.timeEnd("xhr_send:".concat(n)),
"ms,size="
)
.concat(t.response.byteLength, ",有缓存")
);
else {
ze.pluginLog(
"xhr_onload: "
.concat(r, ",耗时=")
.concat(
Ge.timeEnd("xhr_send:".concat(n)),
"ms,size="
)
.concat(t.response.byteLength, ",无缓存")
);
var o = an(n);
(t.cachePath = o),
wn
.writeFile(o, t.response)
.then(function () {
t.triggerEvent("save", o),
t.triggerEvent(
"complete",
new ui({ xhrObj: t, status: ai.Ok })
);
})
.catch(function (e) {
t.triggerEvent("savefail", e),
t.triggerEvent(
"complete",
new ui({
xhrObj: t,
status: ai.Fail,
errMsg: e.errMsg || e.message,
})
);
});
}
} else
t.triggerEvent(
"complete",
new ui({
xhrObj: t,
status: ai.Fail,
errMsg: t.statusText,
})
),
t.reportHttpError({
filename: r,
url: n,
error: t.status,
type: "onload",
});
} else
t.triggerEvent(
"complete",
new ui({ xhrObj: t, status: ai.Ok })
),
t.status !== Nn &&
t.reportHttpError({
filename: tn(n),
url: n,
error: t.status,
type: "onload",
});
})
: "onerror" === n || "ontimeout" === n || "onabort" === n
? (t.originXhr[n] = function (e) {
var a = t.paramsCache.url;
ti.requestMonitor.completeLoad(a, t, e, t.reqId),
t.isFetchApi
? t.triggerEvent("FetchReject", e)
: i(e),
t.handleTaskComplete(),
t.triggerEvent(
"complete",
new ui({
xhrObj: t,
status: ai.Fail,
errMsg: "".concat(n, "_").concat(t.statusText),
})
),
t.reportHttpError({
filename: t.cacheable ? en(a) : tn(a),
url: a,
error: e,
type: n,
});
})
: e.includes(n)
? (t["_".concat(n)] = i)
: (t.originXhr[n] = i);
},
});
}),
[
"abort",
"getAllResponseHeaders",
"getResponseHeader",
"overrideMimeType",
"addEventListener",
"setRequestHeader",
].forEach(function (e) {
Object.defineProperty(t, e, {
value: function () {
var n;
return (
"abort" === e && (t.signal.aborted = !0),
(n = t.originXhr)[e].apply(n, arguments)
);
},
});
});
}),
(this.createResponse = function (e) {
var n = e.data,
i = e.statusCode,
a = void 0 === i ? 200 : i;
void 0 !== a && (t.status = a), n && (t.response = n);
}),
(this.triggerEvent = function (e) {
for (
var n = t["on".concat(e)],
i = arguments.length,
a = new Array(i > 1 ? i - 1 : 0),
r = 1;
r < i;
r++
)
a[r - 1] = arguments[r];
n && n.apply(t, a || []);
}),
(this.originXhr = new d.XMLHttpRequest()),
(this.paramsCache = {}),
this.bindEvent(),
(this.reqId = (function (e) {
for (
var t = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
],
n = "",
i = 0;
i < 10;
i++
)
n += t[Math.floor(36 * Math.random())];
return n;
})());
}
return (
c(e, [
{
key: "handleTaskComplete",
value: function () {
var e = ri.getTaskByUrl(this.paramsCache.url);
e &&
((e.statusCode = this.originXhr.status),
(e.response = this.originXhr.response),
ri.removeTask(e));
},
},
{
key: "reportHttpError",
value: function (t) {
var n,
i = t.filename,
a = t.url,
r = t.error,
o = t.type;
if (dn(a))
e.hasUnityAnalysisLoged ||
((e.hasUnityAnalysisLoged = !0),
ze.debugWarn("[开发版提示]请求无用URL=", a));
else {
var s = !1,
u = ze.pluginError,
c = "number" == typeof r,
l = r;
c ||
"string" == typeof r ||
(l =
(null == r ? void 0 : r.errMsg) ||
(null == r ? void 0 : r.message) ||
"empty errMsg"),
d.isReportableHttpError &&
((null === (n = d.isReportableHttpError) || void 0 === n
? void 0
: n.call(d, { url: a, filename: i, error: r })) ||
((s = !0), (u = ze.debugError))),
u(
"xhr_".concat(o, ": ").concat(i, "下载失败: statusCode="),
!!c && this.status,
", statusText=",
this.statusText,
", networkType=",
yt.networkType,
", isVisible=",
dt(),
", cost=",
this.cacheable ? Ge.timeEnd("xhr_send:".concat(a)) : "-",
"ms, errMsg=",
l,
", error=",
r
),
ua.getInstance().needPluginReport() &&
!s &&
Rt.send(
new kt({
ReportType: Te.LOAD_ASSET_BUNDLE,
ErrorMsg: l,
ErrorType: Number(this.status),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
event: "CacheXMLHttpRequest_"
.concat(o, ": ")
.concat(c ? "statusCode" : "network", " error"),
isReadFromCache: this.isReadFromCache,
cacheable: this.cacheable,
type: o,
url: a,
gameStage: mt(),
}),
})
);
}
},
},
]),
e
);
})();
ci.hasUnityAnalysisLoged = !1;
var li,
hi = N,
di = hi.screenWidth,
fi = hi.screenHeight,
gi = {
body: {
position: "relative",
overflow: "hidden",
hidden: !1,
opacity: 1,
width: di,
height: fi,
},
video: { position: "absolute", top: 0, left: 0, width: di, height: fi },
container: {
position: "absolute",
overflow: "hidden",
hidden: !1,
top: 0,
left: 0,
backgroundColor: "#ffffff",
},
bgImg: { position: "absolute", top: 0, left: 0, width: di, height: fi },
loadingWrap: {
position: "absolute",
overflow: "hidden",
textAlign: "center",
width: 240,
height: 24,
borderRadius: 12,
backgroundColor: "#000000",
opacity: 0.5,
bottom: 64,
left: (di - 240) / 2,
},
loadingInnerWrap: {
position: "absolute",
overflow: "hidden",
width: 236,
height: 20,
bottom: 66,
borderRadius: 10,
left: (di - 240) / 2 + 2,
},
loadingInner: {
position: "absolute",
overflow: "hidden",
width: 236,
height: 20,
borderRadius: 10,
backgroundColor: "#07c160",
top: 0,
left: -236,
},
loadingInnerFake: {
position: "absolute",
overflow: "hidden",
width: 236,
height: 20,
borderRadius: 10,
backgroundColor: "#07c160",
top: 0,
left: -236,
},
loadingInnerSecond: {
position: "absolute",
overflow: "hidden",
width: 236,
height: 20,
borderRadius: 10,
backgroundColor: "#07c160",
top: 0,
left: -236,
},
loadingText: {
position: "absolute",
textAlign: "center",
color: "#ffffff",
letterSpacing: 1,
fontSize: 12,
width: 240,
height: 20,
lineHeight: 20,
},
unityLogo: {
position: "absolute",
width: 64,
height: 24,
bottom: 20,
left: (di - 64) / 2,
},
},
pi = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
mi = N.screenWidth,
vi = N.screenHeight;
function yi(e, t) {
(e.width = t.width),
(e.height = t.height),
(e.backgroundColor = t.backgroundColor),
(e.left = t.left);
}
function Si(e, t, n) {
var i = {},
a = ["width", "right", "left"];
return (
[
"width",
"height",
"top",
"right",
"bottom",
"left",
"backgroundColor",
"color",
"padding",
"fontSize",
"lineHeight",
].forEach(function (r) {
var o = e[r];
if (void 0 !== o || null !== o) {
if ("string" == typeof o && o.includes("%")) {
var s = +o.replace("%", "") / 100;
o = a.includes(r) ? t * s : n * s;
}
i[r] = o;
}
}),
i
);
}
function Ti(e, t) {
(0, _.Kn)(t) &&
Object.keys(t).forEach(function (n) {
(0, _.xb)(t[n]) || (e[n] = t[n]);
});
}
function bi(e, n) {
var i,
a,
r = null,
o = t(e.children);
try {
for (o.s(); !(a = o.n()).done; ) {
var s = a.value;
if (
(null === (i = null == s ? void 0 : s.attributes) || void 0 === i
? void 0
: i.id) === n
) {
r = s;
break;
}
if (s.children.length > 0) {
var u = bi(s, n);
if (null !== u) {
r = u;
break;
}
}
}
} catch (e) {
o.e(e);
} finally {
o.f();
}
return r;
}
function wi(e, t) {
e.children = e.children.filter(function (e) {
return e.attributes.id !== t;
});
}
!(function (e) {
(e.NO_BORDER = "NO_BORDER"),
(e.EXACT_FIT = "EXACT_FIT"),
(e.FIXED_HEIGHT = "FIXED_HEIGHT"),
(e.FIXED_WIDTH = "FIXED_WIDTH"),
(e.SHOW_ALL = "SHOW_ALL"),
(e.FIXED_NARROW = "FIXED_NARROW"),
(e.FIXED_WIDE = "FIXED_WIDE");
})(li || (li = {}));
var Ci;
function Ei() {
var e,
t,
n,
i = this,
a = T(this),
r = C(
'\n <view id="body">\n <view id="container">\n <image\n id="bg-img"\n ></image>\n <video\n id="video"\n controls="false"\n obeyMuteSwitch="true"\n pageGesture="false"\n loop="true"\n muted="true"\n autoplay="false"\n object-fit="cover"\n enable-progress-gesture="false"\n enable-play-gesture="false"\n show-center-play-btn="false"\n auto-insert="false"\n ></video>\n \n <view\n id="loading-wrap"\n ></view>\n <view\n id="loading-inner-wrap"\n >\n <view\n id="loading-inner"\n ></view>\n <view id="loading-inner-fake"></view>\n <view id="loading-inner-second"></view>\n </view>\n\n <text\n id="loading-text"\n value="正在加载"\n ></text>\n\n <image\n id="unity-logo"\n src="images/unity_logo.png"\n ></image>\n </view>\n </view>\n'
).root,
o = JSON.parse(JSON.stringify(gi)),
s = bi(r, "container"),
u = bi(r, "video"),
c = bi(r, "bg-img"),
l = bi(r, "unity-logo");
if (
((o.body.hidden = !this.isVisible), this.materialConfig.backgroundImage)
) {
c.attributes.src = this.materialConfig.backgroundImage;
var h = this.backgroundImageInfo,
d = h.width,
f = h.height;
if (this.isDefaultLoading) {
var g = (d / f) * vi;
if (g < mi) {
var p = (f / d) * mi;
(o.bgImg.width = mi / this.scaleX),
(o.bgImg.height = p / this.scaleY),
(o.bgImg.top = -(p - vi) / 2 / this.scaleY);
} else
(o.bgImg.height = vi / this.scaleY),
(o.bgImg.width = g / this.scaleX),
(o.bgImg.left = -(g - mi) / 2 / this.scaleX);
} else
(o.bgImg.height = this.designHeight),
(o.bgImg.width = this.designWidth),
(o.bgImg.left = 0),
(o.bgImg.top = 0);
} else wi(s, "bg-img");
(null === (e = this.extensionButton) || void 0 === e
? void 0
: e.length) &&
this.extensionButton.forEach(function (e) {
s.children.push({
name: "image",
content: "",
children: [],
attributes: { id: e.id, src: e.image },
});
var t = {};
Object.keys(e.style).forEach(function (n) {
void 0 !== e.style[n] && (t[n] = e.style[n]);
}),
(o[e.id] = Object.assign({ position: "absolute" }, t));
}),
this.materialConfig.backgroundVideo
? (this.isDefaultLoading
? ((o.video.height = vi / this.scaleY),
(o.video.width = mi / this.scaleX))
: ((o.video.height = this.designHeight),
(o.video.width = this.designWidth)),
(u.attributes.src = this.materialConfig.backgroundVideo))
: wi(s, "video"),
this.iconConfig.visible
? (l.attributes.src = this.materialConfig.iconImage)
: wi(s, "unity-logo"),
(o.container.width = this.designWidth),
(o.container.height = this.designHeight),
(o.container.left = (mi - this.designWidth) / 2),
(o.container.top = (vi - this.designHeight) / 2),
(o.container.scaleWidth = this.scaleX),
(o.container.scaleHeight = this.scaleY);
var m = this.barComputedStyle,
v = {
width: m.width,
height: m.height,
borderRadius: m.borderRadius || m.height / 2,
left: m.left || (this.designWidth - m.width) / 2,
bottom: m.bottom,
right: m.right,
top: m.top,
};
Ti(o.loadingWrap, v);
var y = {
width: m.width - 2 * m.padding,
height: m.height - 2 * m.padding,
borderRadius: (m.height - 2 * m.padding) / 2,
backgroundColor: m.backgroundColor,
left: -(m.width - 2 * m.padding),
};
Ti(o.loadingInnerWrap, {
width: y.width,
height: y.height,
borderRadius: y.borderRadius,
left: o.loadingWrap.left + m.padding,
bottom: m.bottom + m.padding,
}),
(this.trueInnerImageWidth = y.width),
yi(o.loadingInner, y),
yi(o.loadingInnerFake, y),
yi(o.loadingInnerSecond, y);
var S = this.textConfig.style;
if (
((o.loadingText.width = S.width),
(o.loadingText.left = (this.designWidth - S.width) / 2),
(o.loadingText.height = S.height),
(o.loadingText.lineHeight = S.height),
(o.loadingText.bottom = S.bottom),
(o.loadingText.color = S.color),
(o.loadingText.fontSize = S.fontSize),
this.iconConfig.visible)
) {
var E = this.iconConfig.style;
(o.unityLogo.width = E.width),
(o.unityLogo.height = E.height),
(o.unityLogo.bottom = E.bottom),
(o.unityLogo.left = (this.designWidth - E.width) / 2);
}
if (
(b.call(this, r, o),
w.add(a.body),
A.isWK && Y && this.iconConfig.visible)
) {
var k = 0;
a.unityLogo.on("click", function () {
3 === (k += 1) && i.destory();
});
}
return (
null ===
(n =
null === (t = null == this ? void 0 : this.extensionButton) ||
void 0 === t
? void 0
: t.forEach) ||
void 0 === n ||
n.call(t, function (e) {
a[e.id].on("click", function () {
var t;
null === (t = null == e ? void 0 : e.callback) ||
void 0 === t ||
t.call(e);
});
}),
a.body.ready()
);
}
!(function (e) {
(e[(e.Downloading = 0)] = "Downloading"),
(e[(e.CompileWasm = 1)] = "CompileWasm"),
(e[(e.PrepareGame = 2)] = "PrepareGame");
})(Ci || (Ci = {}));
var ki = (function (t) {
a(o, t);
var i = r(o);
function o(t) {
var a,
r = t.totalLaunchTime,
s = void 0 === r ? 15e3 : r,
c = t.needDownload,
l = t.hideAfterCallmain,
d = void 0 !== l && l,
f = t.textConfig,
g = t.barConfig,
p = t.materialConfig,
m = t.iconConfig,
v = t.designWidth,
y = t.designHeight,
S = t.scaleMode,
b = t.extensionButton,
C = t.visible;
u(this, o),
((a = i.call(this)).totalLaunchTime = 15e3),
(a.loadingOuterInfo = {}),
(a.loadingInnerInfo = {}),
(a.backgroundImageInfo = {}),
(a.useBackgroundImage = !1),
(a.hideAfterCallmain = !1),
(a.completed = !1),
(a.latestStage = Ci.Downloading),
(a.visible = !1),
(a.load = function () {
return a.isVisible ? T(e(a)).loadPromise : Promise.resolve();
}),
(a.resume = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (e.next = 2), this.load();
case 2:
this.show(),
(e.t0 = this.latestStage),
(e.next =
e.t0 === Ci.Downloading
? 6
: e.t0 === Ci.CompileWasm
? 8
: e.t0 === Ci.PrepareGame
? 10
: 11);
break;
case 6:
return (
this.startDownloadAnimation(),
e.abrupt("break", 11)
);
case 8:
return (
this.showCompileWasm(), e.abrupt("break", 11)
);
case 10:
this.startCompileAnimation();
case 11:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.loadImage = function () {
return (function (e) {
return new Promise(function (t) {
if (e) {
var n = h.createImage();
(n.onload = function () {
t(n);
}),
(n.onerror = function () {
t(null);
}),
(n.src = e);
} else t(null);
});
})(a.materialConfig.backgroundImage).then(function (e) {
e &&
(a.backgroundImageInfo = {
width: e.width,
height: e.height,
});
});
}),
(a.destory = function () {
var t = T(e(a));
t.body.animate({ opacity: 0, duration: 300 }).then(function () {
w.remove(t.body);
});
}),
(a.renderVideo = function () {
if (a.isVisible) {
var t = T(e(a));
t.video &&
((t.video.muted = !1),
t.video.play(),
setTimeout(function () {
t.video.play();
}, 250));
}
}),
(a.show = function () {
return a.isVisible
? ((T(e(a)).body.style.hidden = !1),
a.materialConfig.backgroundVideo && a.renderVideo(),
Promise.resolve())
: Promise.resolve();
}),
(a.hide = function () {
T(e(a)).body.style.hidden = !0;
}),
(a.showCompileWasm = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((this.latestStage = Ci.CompileWasm),
(e.t0 = this.isVisible),
!e.t0)
) {
e.next = 6;
break;
}
return (e.next = 5), this.load();
case 5:
this.setLoadingText(this.textConfig.compilingText);
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.setLoadingText = function (t) {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (((e.t0 = this.isVisible), !e.t0)) {
e.next = 5;
break;
}
return (e.next = 4), this.load();
case 4:
e.t0 = t;
case 5:
if (!e.t0) {
e.next = 7;
break;
}
T(this).loadingText.value = t;
case 7:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.loopText = function (t) {
var n =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: 0,
i = arguments.length > 2 ? arguments[2] : void 0,
r = T(e(a));
if (!r[i] && (null == t ? void 0 : t.length)) {
var o = t[n];
a.needDownload &&
a.textConfig.firstStartText &&
(o += "(".concat(a.textConfig.firstStartText, ")")),
a.setLoadingText(o || "正在加载资源"),
(a.loopTextTimer = setTimeout(function () {
if (!r[i]) {
var e = n + 1 >= t.length ? 0 : n + 1;
a.loopText(t, e, i);
}
}, a.textConfig.textDuration));
}
}),
(a.startDownloadAnimation = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((this.latestStage = Ci.Downloading),
this.isVisible)
) {
e.next = 2;
break;
}
return e.abrupt("return");
case 2:
return (e.next = 4), this.load();
case 4:
(t = T(this)),
this.loopText(
this.textConfig.downloadingText,
0,
"downloaded"
),
t.loadingInner.nextLayout().then(function () {
t.loadingInner.animate({
left:
-0.30000000000000004 *
i.trueInnerImageWidth,
duration: 0.7 * i.totalLaunchTime,
});
});
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.completeDownloadAnimation = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (this.isVisible) {
e.next = 2;
break;
}
return e.abrupt("return");
case 2:
return (e.next = 4), this.load();
case 4:
((t = T(this)).downloaded = !0),
t.loadingInnerFake.nextLayout().then(function () {
t.loadingInnerFake.animate({
left:
-0.30000000000000004 *
i.trueInnerImageWidth,
duration: i.needDownload ? 300 : 200,
});
});
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.startCompileAnimation = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((this.latestStage = Ci.PrepareGame),
this.isVisible)
) {
e.next = 2;
break;
}
return e.abrupt("return");
case 2:
return (e.next = 4), this.load();
case 4:
return (
(t = T(this)),
e.abrupt(
"return",
new Promise(function (e) {
(t.loadingInnerSecond.style.left =
-0.30000000000000004 *
i.trueInnerImageWidth),
t.loadingInnerSecond
.nextLayout()
.then(function () {
i.setLoadingText(i.textConfig.initText),
t.loadingInnerSecond.animate({
left:
-(1 - 0.9) *
i.trueInnerImageWidth,
duration: 0.9 * i.totalLaunchTime,
});
}),
e();
})
)
);
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.completeCompileAnimation = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (this.isVisible) {
e.next = 2;
break;
}
return e.abrupt("return", Promise.resolve());
case 2:
return (e.next = 4), this.load();
case 4:
return (
(t = T(this)),
e.abrupt(
"return",
new Promise(function (e) {
t.downloaded ||
(i.loopTextTimer &&
(clearTimeout(i.loopTextTimer),
(i.loopTextTimer = null)),
i.loopText(
i.textConfig.downloadingText,
0,
"downloaded"
)),
e();
})
)
);
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.completeCallmainAnimation = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (this.isVisible) {
e.next = 2;
break;
}
return e.abrupt("return", Promise.resolve());
case 2:
return (e.next = 4), this.load();
case 4:
return (
(t = T(this)),
e.abrupt(
"return",
new Promise(function (e) {
i.setLoadingText(i.textConfig.completeText),
i.hideAfterCallmain
? t.loadingInnerFake
.nextLayout()
.then(function () {
(t.loadingInnerFake.style.left = 0),
e();
})
: t.loadingInnerFake
.nextLayout()
.then(function () {
(t.compiled = !0),
t.loadingInnerFake
.animate({
left: 0,
duration: 300,
})
.then(e);
});
})
)
);
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.complete = function () {
return pi(
e(a),
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (((e.t0 = this.completed), e.t0)) {
e.next = 7;
break;
}
return (
(this.completed = !0),
(e.next = 5),
this.completeCallmainAnimation()
);
case 5:
return (e.next = 7), this.destory();
case 7:
case "end":
return e.stop();
}
},
e,
this
);
})
);
}),
(a.hideAfterCallmain = d),
(a.totalLaunchTime = s),
(a.needDownload = c);
var E = mi < vi;
if (
((a.isDefaultLoading = !v),
(a.visible = !!(0, _.o8)(C) || !!C),
a.isDefaultLoading)
)
(a.designWidth = mi), (a.designHeight = vi);
else {
var k = E ? 375 : 667,
I = E ? 667 : 375;
(a.designWidth = v || k), (a.designHeight = y || I);
}
(a.barConfig = g),
(a.textConfig = f),
(a.materialConfig = p),
(a.iconConfig = m || {}),
(a.extensionButton = b || []),
(a.scaleMode = S || E ? li.FIXED_WIDTH : li.FIXED_HEIGHT);
var P = T(e(a));
return (
(P.isLoaded = !1),
(P.isShowed = !1),
(P.loadPromise = new Promise(function (t, n) {
Ge.timeStart("loadImage"),
a.loadImage().then(function () {
var i, r, o, s;
(a.stageSize = (function (e, t, n, i, a) {
var r = t,
o = n,
s = i,
u = a,
c = t / s || 0,
l = n / u || 0;
switch (e) {
case li.EXACT_FIT:
break;
case li.FIXED_HEIGHT:
(s = Math.round(t / l)), (c = l);
break;
case li.FIXED_WIDTH:
(u = Math.round(n / c)), (l = c);
break;
case li.NO_BORDER:
c > l
? ((o = Math.round(u * c)), (l = c))
: ((r = Math.round(s * l)), (c = l));
break;
case li.SHOW_ALL:
c > l
? ((r = Math.round(s * l)), (c = l))
: ((o = Math.round(u * c)), (l = c));
break;
case li.FIXED_NARROW:
c > l
? ((s = Math.round(t / l)), (c = l))
: ((u = Math.round(n / c)), (l = c));
break;
case li.FIXED_WIDE:
c > l
? ((u = Math.round(n / c)), (l = c))
: ((s = Math.round(t / l)), (c = l));
break;
default:
(s = t), (u = n);
}
return {
displayWidth: r,
displayHeight: o,
stageWidth: s,
stageHeight: u,
scaleX: c,
scaleY: l,
};
})(S, mi, vi, a.designWidth, a.designHeight)),
(a.offsetX = (mi - a.stageSize.displayWidth) / 2),
(a.offsetY = (vi - a.stageSize.displayHeight) / 2),
(a.displayWidth = a.stageSize.displayWidth),
(a.displayHeight = a.stageSize.displayHeight),
(a.scaleX = a.stageSize.scaleX),
(a.scaleY = a.stageSize.scaleY),
(a.barComputedStyle = Si(
a.barConfig.style,
a.designWidth,
a.designHeight
)),
(a.textComputedStyle = Si(
a.barConfig.style,
a.designWidth,
a.designHeight
)),
(a.extensionButton =
null ===
(s =
null ===
(o =
null ===
(r =
null === (i = a.extensionButton) ||
void 0 === i
? void 0
: i.filter) || void 0 === r
? void 0
: r.call(i, function (e) {
return !!e.style;
})) || void 0 === o
? void 0
: o.map) || void 0 === s
? void 0
: s.call(o, function (e) {
return (
(e.id = "extension".concat((0, _.hQ)(10, !0))),
(e.style = Si(
e.style,
a.designWidth,
a.designHeight
)),
e
);
}));
var u = Ge.timeEnd("loadImage"),
c = Ge.getRuntime();
ze.eventLog("[coverview-loadImage] cost=", u),
Ge.timeStart("coverviewInit"),
Ei.call(e(a))
.then(function () {
var e = Ge.timeEnd("coverviewInit"),
n = Ge.getRuntime();
ze.eventLog("[coverview-init] cost=", e),
ua
.getInstance()
.initReporterPromise.then(function () {
Pt.send([
new kt({
ReportType: Te.LOAD_BACKGROUND_IMAGE,
CostTimeMs: u,
RunTimeMs: c,
ExternInfo: JSON.stringify({
height: a.backgroundImageInfo.height,
width: a.backgroundImageInfo.width,
}),
}),
new kt({
ReportType: Te.COVER_VIEW_INIT,
CostTimeMs: e,
RunTimeMs: n,
}),
]);
}),
t();
})
.catch(function (e) {
ze.pluginError("[coverview-init]", e),
ua
.getInstance()
.initReporterPromise.then(function () {
var t = Ge.timeEnd("coverviewInit"),
n = Ge.getRuntime();
Rt.send(
new kt({
ReportType: Te.COVER_VIEW_INIT,
CostTimeMs: t,
RunTimeMs: n,
ErrorMsg:
(null == e ? void 0 : e.errMsg) ||
(null == e ? void 0 : e.message),
})
);
}),
n(e);
});
});
})),
(P.onProgress = function () {
P.bgImg && (P.bgImg.style.hidden = !0),
P.video && P.video.offProgress(P.onProgress);
}),
a.load().then(function () {
(P.isLoaded = !0), P.video && P.video.onProgress(P.onProgress);
}),
a
);
}
return (
c(o, [
{
key: "isVisible",
get: function () {
return this.visible;
},
set: function (e) {
(this.visible = e), this.visible ? this.resume() : this.hide();
},
},
]),
o
);
})(S),
Ii = N,
Pi = Ii.screenWidth,
Ri = {
body: {
zIndex: 1000009,
position: "absolute",
overflow: "visible",
hidden: !1,
width: 184,
height: 110,
top: Ii.screenHeight / 3,
left: (Pi - 184) / 2,
},
title: {
position: "absolute",
left: 0,
top: 0,
width: 184,
height: 40,
lineHeight: 40,
textAlign: "center",
color: "#ff0000",
fontSize: 18,
fontWeight: 500,
backgroundColor: "#ffffff",
},
restartBtn: {
position: "absolute",
left: 0,
top: 70,
width: 184,
height: 40,
lineHeight: 40,
textAlign: "center",
backgroundColor: "#07C160",
borderRadius: 4,
color: "#ffffff",
fontSize: 16,
},
};
function Ai() {
var e = T(this),
t = C(
'\n <view id="body">\n <text id="title" value="程序遇到错误"></text>\n <text id="restart-btn" value="重启游戏"></text>\n </view>\n'
).root,
n = JSON.parse(JSON.stringify(Ri));
return (
b.call(this, t, n),
w.add(e.body),
e.restartBtn.on("click", function () {
h.restartMiniProgram && h.restartMiniProgram({});
}),
e.body.ready()
);
}
var Li = (function (t) {
a(i, t);
var n = r(i);
function i() {
var t;
return (
u(this, i),
((t = n.call(this)).create = function () {
return T(e(t)).createPromise();
}),
(t.destory = function () {
var n = T(e(t));
n.body.animate({ opacity: 0, duration: 300 }).then(function () {
w.remove(n.body);
});
}),
(T(e(t)).createPromise = new Promise(function (n, i) {
Ai.call(e(t)).then(n).catch(i);
})),
t
);
}
return (
c(i, null, [
{
key: "getInstance",
value: function () {
return i.instance || (i.instance = new i()), i.instance;
},
},
]),
i
);
})(S);
function Di(e) {
var t = Number(e);
return Number(e)
? t < De.Min || t > De.Max
? De.Default
: t
: De.Default;
}
var Mi,
xi = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
Fi = (function () {
function e() {
u(this, e), (this.privateFs = null);
}
return (
c(
e,
[
{
key: "setFs",
value: function (e) {
this.privateFs = e;
},
},
{
key: "statSync",
value: function (e, t) {
try {
return this.privateFs.statSync(e, t);
} catch (t) {
return (
ze.pluginError("PrivateFs_statSync: ", e, t.errMsg, t),
null
);
}
},
},
{
key: "statAsyncCatch",
value: function (e, t) {
var n = this;
return new Promise(function (i) {
n.privateFs.stat({
path: e,
recursive: t,
success: function (e) {
i(e.stats);
},
fail: function () {
i(null);
},
});
});
},
},
{
key: "access",
value: function (e) {
return xi(
this,
void 0,
void 0,
n().mark(function t() {
var i = this;
return n().wrap(function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
return t.abrupt(
"return",
new Promise(function (t, n) {
i.privateFs.access({
path: e,
success: t,
fail: n,
});
})
);
case 1:
case "end":
return t.stop();
}
}, t);
})
);
},
},
{
key: "mkdir",
value: function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: ve;
return xi(
this,
void 0,
void 0,
n().mark(function i() {
var a,
r = this;
return n().wrap(function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
return (
(a = Yt(t, nn(e))),
n.abrupt(
"return",
new Promise(function (e, t) {
r.access(a)
.then(function () {
e(null);
})
.catch(function () {
r.privateFs.mkdir({
dirPath: a,
recursive: !0,
success: e,
fail: function (n) {
if (n.errMsg.includes("exist"))
return e(null);
ze.pluginWarn(
"私有目录创建目录失败: ",
a,
n.errMsg,
n
),
t(n);
},
});
});
})
)
);
case 2:
case "end":
return n.stop();
}
}, i);
})
);
},
},
{
key: "writeFile",
value: function (e, t) {
return xi(
this,
void 0,
void 0,
n().mark(function i() {
var a = this;
return n().wrap(
function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
return (n.next = 2), this.mkdir(e);
case 2:
return n.abrupt(
"return",
new Promise(function (n, i) {
var r = en(e);
a.privateFs.writeFile({
filePath: e,
data: t,
encoding: "binary",
success: function () {
ze.pluginLog(
"私有目录写入 ".concat(r, " 成功")
),
n(null);
},
fail: function (e) {
ze.pluginWarn(
"私有目录写入 ".concat(r, " 失败"),
e
),
i(e);
},
});
})
);
case 3:
case "end":
return n.stop();
}
},
i,
this
);
})
);
},
},
{
key: "readFile",
value: function (e, t) {
var n = this;
return new Promise(function (i, a) {
n.privateFs.readFile({
filePath: e,
encoding: t,
success: function (e) {
if (A.isIOS && !A.isWK) {
var t = vn(new Uint8Array(e.data)),
n = s(t, 1)[0];
e.data = n;
}
i(e.data);
},
fail: a,
});
});
},
},
{
key: "readJson",
value: function (e) {
var t =
!(arguments.length > 1 && void 0 !== arguments[1]) ||
arguments[1];
return xi(
this,
void 0,
void 0,
n().mark(function i() {
var a, r, o, u;
return n().wrap(
function (n) {
for (;;)
switch ((n.prev = n.next)) {
case 0:
if (!e) {
n.next = 10;
break;
}
return (
(n.next = 3), $e(this.readFile(e, "utf-8"))
);
case 3:
if (
((a = n.sent),
(r = s(a, 2)),
(o = r[0]),
!(u = r[1]) || "string" != typeof u)
) {
n.next = 9;
break;
}
return n.abrupt("return", JSON.parse(u));
case 9:
o &&
t &&
ze.pluginWarn(
"私有目录读取json: ".concat(e, "失败"),
o.errMsg || o.message,
o
);
case 10:
return n.abrupt("return", null);
case 11:
case "end":
return n.stop();
}
},
i,
this
);
})
);
},
},
{
key: "writeJson",
value: function (e, t) {
if (e && t) {
var n = JSON.stringify(t);
this.privateFs.writeFile({
filePath: e,
data: n,
encoding: "utf-8",
success: function () {
ze.pluginLog("私有目录写入json: ".concat(e, "成功"));
},
fail: function (t) {
ze.pluginWarn(
"私有目录写入json: ".concat(e, "失败"),
t.errMsg,
t
);
},
});
}
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})().getInstance(),
_i = f(865).default,
Oi = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
Ni = (function () {
function e() {
var t = this;
u(this, e),
(this.patchInstantiated = !1),
(this.patchFetched = !1),
(this.useCodeSplit = !0),
(this.isNewRuntime = !1),
(this.supportPrivateFs = !1),
(this.canUsePatch = te),
(this.patchBasePath = "".concat(me, "/__PATCH_DIR")),
(this.fs = wn),
(this.createTime = 0),
(this.isBr = !1),
(this.md5 = ""),
(this.subVersion = 0),
(this.patchPath = ""),
(this.brPatchPath = ""),
(this.defaultPatchPath = ""),
(this.needFetchPatch = !0),
(this.instantiatePatch = function (e, i) {
return Oi(
t,
void 0,
void 0,
n().mark(function e() {
var t,
a,
r,
o = this;
return n().wrap(function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(t = !1),
(a = Oi(
o,
void 0,
void 0,
n().mark(function e() {
var t, a, r;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((t = Ue.get(We) !== Fe.open),
this.canUsePatch && !t)
) {
e.next = 3;
break;
}
return e.abrupt(
"return",
(ze.pluginWarn(
t
? "禁用patch包"
: "基础库版本过低,不支持使用patch包"
),
Promise.resolve(null))
);
case 3:
return (
(e.next = 5), this.initConfigPromise
);
case 5:
return (
(e.next = 7), this.fetchPatchPromise
);
case 7:
return (
(e.next = 9), this.statPatchFile()
);
case 9:
if (e.sent) {
e.next = 11;
break;
}
return e.abrupt(
"return",
(ze.pluginWarn(
"[非报错可忽略]patch文件不存在"
),
Promise.resolve(null))
);
case 11:
if (this.isPatchMatched()) {
e.next = 13;
break;
}
return e.abrupt(
"return",
(ze.pluginLog(
"[非报错可忽略]patch版本不匹配"
),
Promise.resolve(null))
);
case 13:
return (
(e.prev = 13),
ze.eventLog("开始编译patch"),
Ge.timeStart("instantiatePatch"),
(e.next = 17),
WXWebAssembly.instantiate(
this.patchPath,
i
)
);
case 17:
return (
(a = e.sent),
(this.patchInstantiated = !0),
(r =
Ge.timeEnd("instantiatePatch")),
e.abrupt(
"return",
(ze.eventLog(
"patch编译耗时: ",
r,
"ms"
),
Pt.send(
new kt({
ReportType: ke.COMPILE_PATCH,
CostTimeMs: r,
RunTimeMs: Ge.getRuntime(),
})
),
Promise.resolve(a))
)
);
case 23:
return (
(e.prev = 23),
(e.t0 = e.catch(13)),
e.abrupt(
"return",
(ze.pluginWarn(
"[非报错可忽略]patch编译失败",
e.t0
),
Rt.send(
new kt({
ReportType: ke.COMPILE_PATCH,
ErrorMsg: "".concat(e.t0),
RunTimeMs: Ge.getRuntime(),
})
),
Ge.timeEnd("instantiatePatch"),
Promise.reject(e.t0))
)
);
case 26:
case "end":
return e.stop();
}
},
e,
this,
[[13, 23]]
);
})
)).finally(function () {
t = !0;
}),
(r = new Promise(function (e) {
setTimeout(function () {
if (t) return e(null);
ze.eventLog(
"长时间未完成下载/编译patch, 跳过patch能力"
),
e(null);
}, 1e4);
})),
e.abrupt("return", Promise.race([r, a]))
);
case 5:
case "end":
return e.stop();
}
}, e);
})
);
});
var i = !!I,
a = null == I ? void 0 : I(),
r = A.isIOS && (0, _.yC)(A.systemInfo.version, "8.0.30") >= 0,
o = A.isAndroid && (0, _.yC)(A.systemInfo.version, "8.0.27") >= 0;
i &&
a &&
(r || o) &&
((this.supportPrivateFs = !0),
(this.patchBasePath = "".concat(ve, "/__PATCH_DIR")),
Fi.setFs(a),
(this.fs = Fi)),
(this.patchConfigPath = "".concat(
this.patchBasePath,
"/patchconfig.json"
)),
(this.brPatchPath = "".concat(
this.patchBasePath,
"/patch.wasm.br"
)),
(this.defaultPatchPath = "".concat(
this.patchBasePath,
"/patch.wasm"
)),
this.fs.mkdir("", this.patchBasePath),
ze.eventLog(
"使用".concat(
this.supportPrivateFs ? "私有" : "公共",
"目录存储patch"
)
);
}
return (
c(
e,
[
{
key: "updateCodeType",
value: function (e) {
(this.useCodeSplit = e),
(this.isNewRuntime = J && !!this.useCodeSplit),
this.useCodeSplit && this.checkNeedFetchPatch();
},
},
{
key: "isPatchMatched",
value: function () {
return (
this.subVersion === d.WASM_SPLIT_SUB_VERSION &&
this.md5 === d.CODE_FILE_MD5
);
},
},
{
key: "checkNeedFetchPatch",
value: function () {
return Oi(
this,
void 0,
void 0,
n().mark(function e() {
var t;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(this.initConfigPromise = this.initConfig()),
(e.next = 3),
this.initConfigPromise
);
case 3:
(t = e.sent),
ze.eventLog(
"本地".concat(
t
? "有patch, createTime=".concat(
this.createTime
)
: "无patch",
", 拉取最新patch"
)
),
(this.needFetchPatch = !0),
(this.fetchPatchPromise =
this.fetchPatchFile());
case 5:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "initConfig",
value: function () {
return Oi(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (e.next = 2), this.readConfig();
case 2:
return (e.next = 4), this.statPatchFile();
case 4:
return e.abrupt("return", e.sent);
case 5:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "statPatchFile",
value: function () {
return Oi(
this,
void 0,
void 0,
n().mark(function e() {
var t;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(e.next = 2),
this.fs.statAsyncCatch(
this.isBr
? this.brPatchPath
: this.defaultPatchPath
)
);
case 2:
return (
(t = e.sent),
e.abrupt(
"return",
(ze.pluginLog(
"本地是否有patch文件="
.concat(!!t, ", isbrotli=")
.concat(this.isBr)
),
!!t)
)
);
case 4:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "readConfig",
value: function () {
return Oi(
this,
void 0,
void 0,
n().mark(function e() {
var t;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(e.next = 2),
this.fs.readJson(this.patchConfigPath, !1)
);
case 2:
(t = e.sent),
ze.pluginLog("patch配置读取完毕", t),
t &&
((this.createTime = t.createTime),
(this.isBr = t.isBr),
(this.md5 = t.md5),
(this.subVersion = t.subVersion),
(this.patchPath = this.isBr
? this.brPatchPath
: this.defaultPatchPath));
case 4:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "fetchPatchFile",
value: function () {
return Oi(
this,
void 0,
void 0,
n().mark(function e() {
var t = this;
return n().wrap(function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (_i.env.isMiniGamePlugin) {
e.next = 2;
break;
}
return e.abrupt(
"return",
(ze.pluginLog("非插件模式不拉取patch"),
Promise.resolve(!1))
);
case 2:
return e.abrupt(
"return",
Ue.get(We) !== Fe.open
? (ze.pluginLog(
"已禁用patch, 不拉取最新patch"
),
Promise.resolve(!1))
: new Promise(function (e) {
Ge.timeStart("fetchwasmpatch"),
_i.network
.gameTransfer({
url: "gamewxagwasmsplit_getwasmpatch",
data: {
meta_info: {
md5: d.CODE_FILE_MD5,
sub_version:
d.WASM_SPLIT_SUB_VERSION,
},
is_ios_new_runtime: Boolean(
t.isNewRuntime
),
last_patch_create_time:
t.createTime,
},
})
.then(function (n) {
var i = s(n, 1)[0];
if (
((t.patchFetched = !0),
ze.eventLog(
"gamewxagwasmsplit_getwasmpatch success, 有无更新: ".concat(
!!i.buffer
)
),
i.buffer)
) {
t.isBr = !!i.is_br;
var a = (function (e, t) {
for (
var n,
i,
a,
r = e.replace(
/[^A-Za-z0-9+/]/g,
""
),
o = r.length,
s =
1 *
Math.ceil(
((3 * o + 1) >>> 2) / 1
),
u = new Uint8Array(s),
c = 0,
l = 0,
h = 0;
h < o;
h++
)
if (
((i = 3 & h),
(c |=
((a = r.charCodeAt(h)) >
64 && a < 91
? a - 65
: a > 96 && a < 123
? a - 71
: a > 47 && a < 58
? a + 4
: 43 === a
? 62
: 47 === a
? 63
: 0) <<
(18 - 6 * i)),
3 === i || o - h == 1)
) {
for (
n = 0;
n < 3 && l < s;
n++, l++
)
u[l] =
(c >>>
((16 >>> n) & 24)) &
255;
c = 0;
}
return u;
})(i.buffer).buffer;
(t.patchPath = t.isBr
? t.brPatchPath
: t.defaultPatchPath),
ze.eventLog(
"最新patch大小: "
.concat(
a.byteLength,
"byte, createTime="
)
.concat(
i.create_time,
", isbrotli="
)
.concat(
t.isBr,
", fetchcost="
)
.concat(
Ge.timeEnd(
"fetchwasmpatch"
)
)
),
Ge.timeStart("writePatch"),
t.fs
.writeFile(t.patchPath, a)
.then(function () {
(t.subVersion =
d.WASM_SPLIT_SUB_VERSION),
(t.md5 = d.CODE_FILE_MD5),
ze.eventLog(
"patch包缓存成功"
),
Pt.send(
new kt({
ReportType:
ke.WRITE_PATCH,
CostTimeMs:
Ge.timeEnd(
"writePatch"
),
RunTimeMs:
Ge.getRuntime(),
})
),
e(!0);
})
.catch(function (t) {
ze.pluginWarn(
"[不影响游戏可忽略]patch包缓存失败: ",
t
),
Ge.timeEnd("writePatch"),
Rt.send(
new kt({
ReportType:
ke.WRITE_PATCH,
RunTimeMs:
Ge.getRuntime(),
ErrorMsg: "".concat(
t
),
})
),
e(!1);
}),
t.fs.writeJson(
t.patchConfigPath,
{
createTime: i.create_time,
isBr: t.isBr,
md5: d.CODE_FILE_MD5,
subVersion:
d.WASM_SPLIT_SUB_VERSION,
}
);
} else e(!1);
})
.catch(function (t) {
ze.pluginWarn(
"[不影响游戏可忽略]拉取patch更新失败: ",
t
),
Rt.send(
new kt({
ReportType: ke.DOWNLOAD_PATCH,
ErrorMsg: "".concat(t),
RunTimeMs: Ge.getRuntime(),
})
),
e(!1);
});
})
);
case 3:
case "end":
return e.stop();
}
}, e);
})
);
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})().getInstance(),
Wi = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "init",
value: function (e) {
(this.unityManager = e), this.bindFunction();
},
},
{ key: "bindFunction", value: function () {} },
]),
n
);
})(ce);
!(function (e) {
(e[(e.FETCH_SNAPSHOT = 70)] = "FETCH_SNAPSHOT"),
(e[(e.RESTORE_SNAPSHOT = 71)] = "RESTORE_SNAPSHOT");
})(Mi || (Mi = {}));
var Ui = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "fetchSnapshot",
value: function (e) {
this.baseReporter(Mi.FETCH_SNAPSHOT, e);
},
},
{
key: "restoreSnapshot",
value: function (e) {
this.baseReporter(Mi.RESTORE_SNAPSHOT, e);
},
},
{
key: "baseReporter",
value: function (e, t) {
var n = new kt({ ReportType: e, RunTimeMs: Ge.getRuntime() });
(0, _.o8)(t) || (n.CostTimeMs = t), Pt.send(n);
},
},
{
key: "bindFunction",
value: function () {
this.unityManager.reporter.snapshot = {
fetchSnapshot: this.fetchSnapshot.bind(this),
restoreSnapshot: this.restoreSnapshot.bind(this),
};
},
},
]),
n
);
})(Wi).getInstance(),
Bi = "/System/Library/Fonts/LanguageSupport",
Gi = (function () {
function e() {
u(this, e), (this.needReport = void 0), (this.reportInfo = {});
}
return (
c(
e,
[
{
key: "init",
value: function (e) {
this.bindInterface(e);
},
},
{
key: "bindInterface",
value: function (e) {
(e.font = e.font || {}),
oe && P && Ue.get("wxfont") === Fe.open
? ((e.font.getCommonFont = this.getCommonFont.bind(this)),
(e.font.canUseWxFont = !0))
: (e.font.canUseWxFont = !1),
(e.font.reportGetFontCost =
this.reportGetFontCost.bind(this));
},
},
{
key: "getCommonFont",
value: function (e) {
var t = this,
n = e.success,
i = e.fail;
Ge.timeStart("getSystemFontList"),
P({
path: A.isAndroid ? "/system/fonts" : Bi,
success: function (e) {
var a = Ge.timeEnd("getSystemFontList");
ze.pluginLog("[font]扫描字体列表耗时=".concat(a, "ms"));
var r = A.isAndroid
? "NotoSansCJK-Regular"
: "PingFang",
o = e.data.find(function (e) {
return e.includes(r);
});
if (o) {
var s = A.isIOS
? [
[19968, 40959],
[0, 127],
[12288, 12351],
[8192, 8303],
[12800, 13055],
[65040, 65055],
[65072, 65103],
[9728, 9983],
[13056, 13311],
[65280, 65519],
[9984, 10175],
[8448, 8527],
[9312, 9471],
[8528, 8591],
[8352, 8399],
[8592, 8703],
[9632, 9727],
[8704, 8959],
]
: void 0,
u = A.isAndroid ? o : Yt(Bi, o);
Ge.timeStart("getSystemFontData"),
P({
path: u,
subset: s,
success: function (e) {
var r = e.data;
if (r) {
var o = Ge.timeEnd("getSystemFontData");
ze.pluginLog(
"[font]读取字体文件耗时="
.concat(o, "ms, 字体大小=")
.concat(
(r.byteLength / 1024 / 1024).toFixed(2),
"MB"
)
),
n(r),
t.reportFontUsage({
scanDirCost: a,
readFontDataCost: o,
byteLength: r.byteLength,
});
} else {
Ge.timeEnd("getSystemFontData"),
ze.pluginLog("[font]无字体文件内容");
var s = "empty font file";
t.reportFontError({ errMsg: s }),
i({ errmsg: s });
}
},
fail: function (e) {
Ge.timeEnd("getSystemFontData"),
t.reportFontError(e),
i(e);
},
});
} else {
ze.pluginLog("[font]无中文字体");
var c = "no support font";
t.reportFontError({ errMsg: c }), i({ errmsg: c });
}
},
fail: function (e) {
Ge.timeEnd("getSystemFontList"),
this.reportFontError(e),
i(e);
},
});
},
},
{
key: "reportFontUsage",
value: function (e) {
var t = e.scanDirCost,
n = e.readFontDataCost,
i = e.byteLength;
(this.needReport = !X || (X && Math.random() < 0.2)),
this.needReport &&
(this.reportInfo = {
scanDirCost: t,
readFontDataCost: n,
byteLength: i,
});
},
},
{
key: "reportFontError",
value: function (e) {
var t = e.errMsg;
Rt.send(
new kt({
ReportType: we.FONT,
ErrorMsg: t,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({ system: N.system }),
})
);
},
},
{
key: "reportGetFontCost",
value: function (e, t) {
void 0 === this.needReport &&
(this.needReport = !X || (X && Math.random() < 0.2)),
this.needReport &&
(Pt.send(
new kt({
ReportType: we.FONT,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify(
Object.assign(Object.assign({}, this.reportInfo), {
invokePendingCost: e,
loadFromRemote: t.loadFromRemote,
isReadFromCache: t.isReadFromCache,
preload: t.preloadWXFont,
})
),
})
),
(this.reportInfo = null));
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance || (e.instance = new e()), e.instance;
},
},
]
),
e
);
})(),
Vi = f(865).default,
zi = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
};
function ji() {
var e =
arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "";
return zi(
this,
void 0,
void 0,
n().mark(function t() {
var i;
return n().wrap(function (t) {
for (;;)
switch ((t.prev = t.next)) {
case 0:
return (
Ge.timeStart("refreshToken"),
(i = {
auth_payload: {
md5: d.CODE_FILE_MD5,
sub_version: d.WASM_SPLIT_SUB_VERSION,
},
}),
t.abrupt(
"return",
(e && (i.last_token = e),
Vi.network
.gameTransfer({
url: "unity.refreshcontexttoken",
flat: !0,
data: i,
})
.then(function (e) {
var t,
n = s(e, 1)[0];
if (
(ze.pluginLog(
"[auth] refresh token cost=".concat(
Ge.timeEnd("refreshToken"),
"ms"
)
),
null === (t = null == n ? void 0 : n.rsp_list) ||
void 0 === t
? void 0
: t.length)
) {
var i = (
n.rsp_list.find(function (e) {
return "auth_token" === e.key;
}) || {}
).value;
if (i) return Promise.resolve(i);
}
return Promise.reject({ errmsg: "system error" });
})
.catch(function (e) {
return Promise.reject(e);
}))
)
);
case 3:
case "end":
return t.stop();
}
}, t);
})
);
}
var Hi = (function (e) {
a(i, e);
var t = r(i);
function i() {
var e;
return (
u(this, i),
((e = t.apply(this, arguments)).token = ""),
(e.skipAuth = !1),
e
);
}
return (
c(i, [
{
key: "init",
value: function (e) {
this.bindInterface(e), this.autoRefreshToken();
},
},
{
key: "autoRefreshToken",
value: function () {
var e = this;
if (!A.isWK)
return (
(this.refreshTokenPromise = Promise.resolve("")),
void (this.skipAuth = !0)
);
setTimeout(function () {
e.autoRefreshToken();
}, 24e5),
(this.refreshTokenPromise = this.getAuthToken());
},
},
{
key: "getAuthToken",
value: function () {
return (function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
})(
this,
void 0,
void 0,
n().mark(function e() {
var t, i, a, r;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
(e.next = 2),
(0, _.zI)((0, _.gj)(ji, 1, 1, this.token))
);
case 2:
return (
(t = e.sent),
(i = s(t, 2)),
(a = i[0]),
(r = i[1]),
e.abrupt(
"return",
(a
? (ze.pluginError(
"获取authtoken失败, err=",
a
),
(this.skipAuth = !0),
ze.eventLog("跳过鉴权"))
: ((this.skipAuth = !1),
(this.token = r),
ze.pluginLog(
"获取token成功, token=",
this.token
)),
this.token)
)
);
case 7:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "bindInterface",
value: function (e) {
(e.wasmsplit = e.wasmsplit || {}),
(e.wasmsplit.innerInvokeWasmFunc =
this.innerInvokeWasmFunc.bind(this)),
(e.wasmsplit.instantiatePatch = Ni.instantiatePatch),
(e.instantiatePatch = Ni.instantiatePatch);
},
},
{
key: "innerInvokeWasmFunc",
value: function (e) {
var t = e.name,
n = e.invokeWasmFunc,
i = e.fail,
a = {
md5: JSON.stringify({
md5: d.CODE_FILE_MD5,
auth_token: encodeURIComponent(this.token),
}),
subVersion: d.WASM_SPLIT_SUB_VERSION,
funcName: t,
fail: i,
};
this.skipAuth && (a.md5 = d.CODE_FILE_MD5), n(a);
},
},
]),
i
);
})(ce).getInstance(),
qi = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "malloc",
value: function (e) {
if ((0, _.xb)(e))
return ze.pluginError("[malloc report]: invalid params");
var t = new kt({
ReportType: Ie.Malloc,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify(e),
});
Rt.send(t);
},
},
{
key: "bindFunction",
value: function () {
this.unityManager.reporter.alarm = {
malloc: this.malloc.bind(this),
};
},
},
]),
n
);
})(Wi).getInstance(),
Qi = f(865).default,
Ki = (function (e) {
a(n, e);
var t = r(n);
function n() {
var e;
return (
u(this, n),
((e = t.apply(this, arguments)).beforeLoadSubWasm = function () {
ti.wasmSplitMonitor.startLoadSubWasm(),
Ge.printRuntime("首次加载subwasm"),
Pt.send(
new kt({
ReportType: ke.BEFORE_LOAD_SUB_WASM,
CostTimeMs: 0,
RunTimeMs: Ge.getRuntime(),
})
),
(!e.unityManager.mainCalled ||
Ge.timeEnd("游戏主场景耗时", !1) < 100) &&
(ze.eventLog("subwasm在callmain完成前加载"),
Pt.send(
new kt({
ReportType: ke.LOAD_SUB_WASM_VERY_EARLY,
CostTimeMs: 0,
RunTimeMs: Ge.getRuntime(),
})
));
}),
(e.reportMissElem = function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: { miss_elem_list: [], sub_version: 0 },
t = e.miss_elem_list,
n = e.sub_version,
i = N.model;
Qi.network
.gameTransfer({
url: "gamewxagwasmsplitwap_reportsplitmisselem",
data: {
device: i,
miss_elem_list: t,
meta_info: { md5: d.CODE_FILE_MD5, sub_version: Number(n) },
},
})
.then(function (e) {
var t = s(e, 1)[0];
ze.eventLog("reportsplitmisselem success ", t);
})
.catch(function (e) {
ze.pluginError("reportsplitmisselem fail ", e);
});
}),
(e.reportCalledFuncs = function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: { called_func_list: [], sub_version: 0, func_type: 0 },
t = e.called_func_list,
n = e.sub_version,
i = e.func_type,
a = N.model;
Qi.network
.gameTransfer({
url: "gamewxagwasmsplitwap_reportsplitcalledfuncs",
data: {
device: a,
called_func_list: t,
func_type: i,
meta_info: { md5: d.CODE_FILE_MD5, sub_version: Number(n) },
},
})
.then(function (e) {
var t = s(e, 1)[0];
ze.eventLog("reportsplitcalledfuncs success ", t);
})
.catch(function (e) {
ze.pluginError("reportsplitcalledfuncs fail ", e);
});
}),
e
);
}
return (
c(n, [
{
key: "startFetchJsCode",
value: function () {
Ge.printRuntime("首次拉取js函数"),
Pt.send(
new kt({
ReportType: ke.FETCH_JS,
RunTimeMs: Ge.getRuntime(),
})
),
(!this.unityManager.mainCalled ||
Ge.timeEnd("游戏主场景耗时", !1) < 100) &&
(ze.eventLog("在callmain完成前fetchjs"),
Pt.send(
new kt({
ReportType: ke.LOAD_SUB_WASM_VERY_EARLY,
CostTimeMs: 0,
RunTimeMs: Ge.getRuntime(),
})
));
},
},
{
key: "reportWaitTime",
value: function (e) {
ze.eventLog("加载subwasm时,signal wait时长: ".concat(e)),
Pt.send(
new kt({
ReportType: ke.WAIT_SUB_WASM_END,
CostTimeMs: e,
RunTimeMs: Ge.getRuntime(),
})
);
},
},
{
key: "subWasmDownloaded",
value: function (e) {
ti.wasmSplitMonitor.finishLoadSubWasm(),
ze.eventLog("subwasm下载耗时 ", e),
Pt.send(
new kt({
ReportType: ke.SUB_WASM_LOAD,
CostTimeMs: e,
RunTimeMs: Ge.getRuntime(),
})
);
},
},
{
key: "subWasmDownloadError",
value: function (e) {
ze.pluginError("subwasm下载失败 ", e),
Rt.send(
new kt({
ReportType: ke.SUB_WASM_LOAD,
ErrorMsg: "".concat(e.statusCode, "__").concat(e.errMsg),
RunTimeMs: Ge.getRuntime(),
})
);
},
},
{
key: "subWasmCompiled",
value: function (e) {
ze.eventLog("subwasm编译耗时 ", e),
Pt.send(
new kt({
ReportType: ke.SUB_WASM_COMPILED,
CostTimeMs: e,
RunTimeMs: Ge.getRuntime(),
})
);
},
},
{
key: "bindFunction",
value: function () {
(this.unityManager.reporter.wasmcode = {
reportMissElem: this.reportMissElem.bind(this),
reportCalledFuncs: this.reportCalledFuncs.bind(this),
startFetchJsCode: this.startFetchJsCode.bind(this),
reportWaitTime: this.reportWaitTime.bind(this),
beforeLoadSubWasm: this.beforeLoadSubWasm.bind(this),
subWasmDownloaded: this.subWasmDownloaded.bind(this),
subWasmDownloadError: this.subWasmDownloadError.bind(this),
subWasmCompiled: this.subWasmCompiled.bind(this),
}),
Object.defineProperties(this.unityManager, {
reportMissElem: { value: this.reportMissElem.bind(this) },
reportCalledFuncs: {
value: this.reportCalledFuncs.bind(this),
},
startFetchJsCode: {
value: this.startFetchJsCode.bind(this),
},
reportWaitTime: { value: this.reportWaitTime.bind(this) },
beforeLoadSubWasm: {
value: this.beforeLoadSubWasm.bind(this),
},
subWasmDownloaded: {
value: this.subWasmDownloaded.bind(this),
},
subWasmDownloadError: {
value: this.subWasmDownloadError.bind(this),
},
subWasmCompiled: { value: this.subWasmCompiled.bind(this) },
});
},
},
]),
n
);
})(Wi).getInstance(),
Xi = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
Zi = (function (t) {
a(o, t);
var i = r(o);
function o() {
var t;
return (
u(this, o),
((t = i.apply(this, arguments)).subWasmModuleName = "wasmcode1"),
(t.retryCount = 1),
(t.retryDuration = 1500),
(t.pendingDuration = 6e4),
(t.invokeLoadWasmCode = function (i) {
return new Promise(function (a, r) {
var o = 0 === i,
s = !1,
u = e(t).unityManager;
Qe.triggerEvent(Ve.WasmLoading, Ke(Xe, u)),
u.launchStage.setProgress(Te.LOAD_SUBPACKAGE, {
progress: 0,
status: Ln.PENDING,
}),
Ge.timeStart("下载wasm代码包"),
ze.eventLog("开始下载wasm代码包"),
h
.loadSubpackage({
name: t.moduleName,
success: function () {
return Xi(
e(t),
void 0,
void 0,
n().mark(function e() {
var t;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
(this.setWasmInfo(),
Qe.triggerEvent(
Ve.WasmLoaded,
Ke(Xe, u)
),
Ge.printTime("下载wasm代码包"),
u.launchStage.setProgress(
Te.LOAD_SUBPACKAGE,
{
progress: 100,
status: Ln.FULFILLED,
}
),
u.triggerLaunchProgress(
Te.LOAD_SUBPACKAGE,
Ge.timeEnd("下载wasm代码包", !1)
),
!ti.enableMonitor)
) {
e.next = 6;
break;
}
return (
ti.commonMonitor.recordWasm({
duration: Ge.timeEnd(
"下载wasm代码包",
!1
),
}),
(e.next = 4),
wn.getFileSize("".concat(this.wasmPath))
);
case 4:
(t = e.sent),
ti.commonMonitor.recordWasm({
contentLength: t,
});
case 6:
Pt.send(
new kt({
ReportType: Te.LOAD_SUBPACKAGE,
CostTimeMs:
Ge.timeEnd("下载wasm代码包"),
RunTimeMs: Ge.getRuntime(),
})
),
setTimeout(function () {
a();
}, 0);
case 7:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
fail: function (e) {
t.handleDownloadError(e, o), r(e);
},
complete: function () {
(s = !0),
(u.loadingCount -= 1),
u.launchStage.setProgress(Te.LOAD_SUBPACKAGE, {
progress: 100,
status: Ln.FULFILLED,
});
},
})
.onProgressUpdate(function (e) {
var t = (e.totalBytesWritten / 1048576).toFixed(2),
n = (e.totalBytesExpectedToWrite / 1048576).toFixed(2);
X ||
ze.pluginLog(
"wasm代码包下载进度",
e.progress,
t,
"MB;",
n,
"MB"
),
u.launchStage.setProgress(Te.LOAD_SUBPACKAGE, {
progress: 100 * e.progress,
});
}),
setTimeout(function () {
s ||
(o && t.handleDownloadError(xe.Wasm, o),
ze.pluginError(xe.Wasm),
r(new Error(xe.Wasm)));
}, t.pendingDuration);
}).then(function () {
var n = e(t).unityManager;
n.loadingPageType === le.COVER_VIEW &&
n.loadingPage.showCompileWasm(),
n.launchStage.setProgress(Te.COMPILE_WASM, {
status: Ln.PENDING,
}),
Hi.refreshTokenPromise.then(function () {
ze.eventLog("start invoke UnityModule"),
d.UnityModule(n.gameInstance.Module),
Qe.triggerEvent(Ve.ModulePrepared);
});
});
}),
t
);
}
return (
c(o, [
{
key: "init",
value: function (e) {
(this.unityManager = e), this.initConfig();
},
},
{
key: "loadWasmCode",
value: function () {
return (0, _.gj)(
this.invokeLoadWasmCode,
this.retryCount,
this.retryDuration
);
},
},
{
key: "parallelFetchSubWasm",
value: function () {
var e = this;
return (
ze.eventLog("loadSubPackage1"),
new Promise(function (t, n) {
Ki.beforeLoadSubWasm(),
Ge.timeStart("subWasmLoad"),
(d._subWasmLoading = !0);
var i = h.loadSubpackage({
name: e.subWasmModuleName,
success: function () {
(d._subWasmLoading = !1),
(d._subWasmLoaded = !0),
console.log(
"[PLUGIN TIME LOG]下载小游戏分包1: ",
Ge.timeEnd("subWasmLoad", !1),
"ms"
),
ze.eventLog("下载代码分包1完毕"),
Ki.subWasmDownloaded(Ge.timeEnd("subWasmLoad")),
t();
},
fail: function (e) {
(d._subWasmLoading = !1),
console.error(
"[PLUGIN SUBWASM ERROR]load subwasm subpackage fail: ",
e
),
Ki.subWasmDownloadError(e),
n();
},
complete: function () {},
}),
a = 0;
i.onProgressUpdate(function (e) {
var t = Math.floor(e.progress / 10);
if (t !== a) {
var n = (e.totalBytesWritten / 1048576).toFixed(2),
i = (e.totalBytesExpectedToWrite / 1048576).toFixed(
2
);
console.log(
"代码分包1下载进度",
e.progress,
n,
"MB;",
i,
"MB"
);
}
a = t;
});
})
);
},
},
{
key: "setWasmInfo",
value: function () {
wn.writeFile(this.filename, new ArrayBuffer(1));
},
},
{
key: "initConfig",
value: function () {
var e = d,
t = e.CODE_FILE_MD5,
n = e.GAME_NAME,
i = J && this.unityManager.codeType === Pe.codeSplit;
(this.moduleName = !re && i ? "wasmcode_wk" : "wasmcode"),
(this.md5 = t),
(this.filename = ""
.concat(this.md5, ".")
.concat(n, ".wasm.code.unityweb.wasm.br")),
(this.wasmPath = ""
.concat(this.moduleName, "/")
.concat(this.filename)),
(this.unityManager.gameInstance.Module.wasmPath =
this.wasmPath);
},
},
{
key: "handleDownloadError",
value: function (e, t) {
var n = e;
if (
("number" == typeof e ||
"string" == typeof e ||
(n = e.errMsg || e.message),
ze.pluginError(
"下载wasm代码包失败",
": networkType=",
yt.networkType,
", isVisible=",
dt(),
", errMsg=",
n,
", error=",
e
),
Rt.send(
new kt({
ReportType: Te.LOAD_SUBPACKAGE,
ErrorMsg: n,
RunTimeMs: Ge.getRuntime(),
})
),
t)
) {
var i = !A.isPC && n === xe.Wasm && !!h.restartMiniProgram;
ze.pluginError("wasm代码包下载最终失败"),
h.showModal({
title: "下载wasm代码包失败",
confirmText: i ? "重启游戏" : "确定",
content: ""
.concat(n)
.concat(
A.isPC && n === xe.Wasm
? "\n请从 微信-小程序-最近使用 重新打开"
: ""
),
showCancel: !1,
success: function () {
i && h.restartMiniProgram({});
},
});
}
},
},
]),
o
);
})(ce).getInstance(),
Ji = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
Yi = (function (e) {
a(i, e);
var t = r(i);
function i() {
var e;
return (
u(this, i),
((e = t.apply(this, arguments)).assetsLoadType = de.DownloadAll),
e
);
}
return (
c(i, [
{
key: "init",
value: function (e) {
(this.unityManager = e), this.initConfig();
},
},
{
key: "getAssetsLoadText",
value: function () {
return Ae[this.assetsLoadType];
},
},
{
key: "needDownload",
get: function () {
return this.assetsLoadType !== de.AllCached;
},
},
{
key: "initAssetsLoadType",
value: function () {
return Ji(
this,
void 0,
void 0,
n().mark(function e() {
var t, i, a;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (e.next = 2), this.getAssetsMd5();
case 2:
(t = e.sent),
(i = t.wasmCached),
(a = t.dataPackageCached),
i && a
? (this.assetsLoadType = de.AllCached)
: i || a
? i && !a
? (this.assetsLoadType =
de.DownloadDataPackage)
: !i &&
a &&
(this.assetsLoadType =
de.DownloadWasmCode)
: (this.assetsLoadType = de.DownloadAll);
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "initConfig",
value: function () {
return Ji(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
this.initAssetsLoadType();
case 1:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "getAssetsMd5",
value: function () {
return Ji(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return e.abrupt(
"return",
new Promise(function (e) {
e({
wasmCached: wn.checkFileExist(
an(Zi.filename)
),
dataPackageCached: wn.checkFileExist(
an(Gn.cachePath)
),
});
})
);
case 1:
case "end":
return e.stop();
}
}, e);
})
);
},
},
]),
i
);
})(ce).getInstance(),
$i = (function (t) {
a(i, t);
var n = r(i);
function i() {
var t;
return (
u(this, i),
((t = n.apply(this, arguments)).runDependencies = 0),
(t.denpendencyIds = []),
(t.onAbort = function (e) {
var n,
i = t.gameInstance.Module,
a = "abort("
.concat(e, ") at ")
.concat(
(
null === (n = null == e ? void 0 : e.stack) ||
void 0 === n
? void 0
: n.toString
)
? e.stack.toString()
: i.stackTrace()
);
Rt.send(
new kt({
ReportType: mt() || Ee.ON_ABORT,
ErrorMsg: "".concat(a).slice(0, 1024),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({ isAbort: !0 }),
})
),
se.warn(a);
}),
(t.wasmInstantiated = function () {
var n,
i = e(t).unityManager;
Qe.triggerEvent(Ve.WasmInstantiated, Ke(Xe, i)),
i.launchStage.setProgress(Te.COMPILE_WASM, {
status: Ln.FULFILLED,
}),
i.launchStage.setProgress(Te.PREPARE_GAME, {
status: Ln.PENDING,
}),
i.loadingPageType === le.COVER_VIEW &&
i.loadingPage.completeCompileAnimation(),
Ge.printTime("wasm编译耗时"),
i.triggerLaunchProgress(
Te.COMPILE_WASM,
Ge.timeEnd("wasm编译耗时", !1)
),
Pt.send(
new kt({
ReportType: Te.COMPILE_WASM,
CostTimeMs: Ge.timeEnd("wasm编译耗时"),
RunTimeMs: Ge.getRuntime(),
})
);
var a = ua.getInstance();
a &&
a.wasmInited &&
"function" == typeof a.wasmInited &&
a.wasmInited(),
i.codeType !== Pe.codeSplit ||
(!ie && Ue.get(Oe) === Fe.open) ||
(t.gameInstance.Module.addRunDependency(
"subWasmInstantiated"
),
null ===
(n = null == i ? void 0 : i.parallelFetchSubWasmTask) ||
void 0 === n ||
n.then(function () {
var e, n;
null ===
(n =
null ===
(e = null == d ? void 0 : d.compileSubWasm) ||
void 0 === e
? void 0
: e.call(d)) ||
void 0 === n ||
n.then(function () {
t.gameInstance.Module.removeRunDependency(
"subWasmInstantiated"
);
});
}));
}),
(t.calledMainCb = function () {
var n = e(t).unityManager;
ri.setConcurrent(1),
ti.preloadMonitor.genResultAfterCallmain(),
ti.showResultAfterDuration(),
(n.mainCalled = !0),
Qe.triggerEvent(Ve.CalledMain, Ke(Xe, n)),
Ge.printTime("callMain耗时"),
Ge.printRuntime("游戏启动耗时"),
Ge.timeStart("游戏主场景耗时"),
n.triggerLaunchProgress(
Te.PREPARE_GAME,
Ge.timeEnd("callMain耗时", !1)
),
ti.commonMonitor.recordCallmain({
duration: Ge.timeEnd("callMain耗时", !1),
launchTime: Ge.getRuntime(),
}),
Pt.send(
new kt({
ReportType: Te.PREPARE_GAME,
CostTimeMs: Ge.timeEnd("callMain耗时"),
RunTimeMs: Ge.getRuntime(),
PreloadedSize: ri.loadedSize || 0,
})
),
ze.pluginLog("callMain完成时已预载资源大小: ", ri.loadedSize),
n.launchStage.setProgress(Te.PREPARE_GAME, {
status: Ln.FULFILLED,
}),
n.loadingPageType === le.LONG_VIDEO
? (n.hideLoadingPage(),
d.Browser &&
(ze.pluginLog("是默认启动页,callMain完成开始游戏主循环"),
d.Browser.mainLoop.resume()))
: n.loadingPageType === le.INTERACTIVE_VIDEO
? (ze.pluginLog("是可交互视频启动页,重新创建渲染器"),
xn.getRenderer().refresh(),
d.isInteractiveEnd &&
(ze.pluginLog(
"callmain结束时已完成可交互阶段,直接显示游戏画面"
),
n.hideFinalPage()))
: n.loadingPageType === le.COVER_VIEW &&
(n.hideAfterCallmain && n.hideLoadingPage(),
d.Browser && d.Browser.mainLoop.resume()),
Gn.releaseDataPackage(),
A.isWK ||
setTimeout(function () {
var e;
null === (e = null == d ? void 0 : d.compileSubWasm) ||
void 0 === e ||
e.call(d);
}, 3e4),
X ||
setTimeout(function () {
n.gameStarted ||
ze.pluginError(
"[开发阶段提示 不影响线上版本]请使用自定义上报能力 WX.ReportGameStart, 便于分析数据做启动优化, 文档: \nhttps://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/ReportStartupStat.md"
);
}, 6e4);
}),
(t.unityFileSystemInit = function () {
var e = t.gameInstance.Module;
e.indexedDB ||
ze.pluginWarn(
"IndexedDB is not available. Data will not persist in cache and PlayerPrefs will not be saved."
),
d.FS.mkdir("/idbfs"),
d.FS.mount(d.IDBFS, {}, "/idbfs"),
e.rawData && e.processRawData();
}),
(t.printErr = function (n) {
var i = e(t).unityManager;
if (
(!i.gameStarted &&
Ge.getRuntime() < 6e4 &&
(et(n) ||
Rt.send(
new kt({
ReportType: mt() || ua.getCurrentStage(!0),
ErrorMsg: "".concat(n).slice(0, 1024),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
mainCalled: i.mainCalled,
}),
})
)),
null == i ? void 0 : i.onLogError)
) {
var a = "string" == typeof n ? n : n.message;
i.onLogError(a);
}
console.error(n);
}),
(t.monitorRunDependencies = function (e, n) {
n &&
(e < t.runDependencies
? (t.denpendencyIds = t.denpendencyIds.filter(function (e) {
return e !== n;
}))
: t.denpendencyIds.push(n)),
(t.runDependencies = e),
0 === t.runDependencies &&
ze.eventLog("no dependencies, invoke run");
}),
t
);
}
return (
c(i, [
{
key: "init",
value: function (e) {
(this.unityManager = e),
this.initInstance(),
this.checkDependenciesRemoved();
},
},
{
key: "checkDependenciesRemoved",
value: function () {
var e = this;
setTimeout(function () {
0 !== e.runDependencies &&
(ze.pluginError(
"still waiting runDependencies, ids=",
e.denpendencyIds
),
Rt.send(
new kt({
ReportType: Ee.WaitingRemoveDependencies,
ExternInfo: JSON.stringify({
runDependencies: e.runDependencies,
denpendencyIds: e.denpendencyIds,
}),
})
));
}, 3e4);
},
},
{
key: "initInstance",
value: function () {
var e = this;
(this.gameInstance = {
onProgress: void 0,
compatibilityCheck: void 0,
Module: {
IsWxGame: !0,
preLoadDataPath: Gn.downloadFilename,
wasmPath: Zi.wasmPath,
graphicsAPI: ["WebGL 2.0", "WebGL 1.0"],
instantiateWasm: d.instantiateWasm,
onAbort: this.onAbort.bind(this),
monitorRunDependencies:
this.monitorRunDependencies.bind(this),
wasmInstantiated: this.wasmInstantiated.bind(this),
onRuntimeInitialized: function () {},
calledMainCb: this.calledMainCb.bind(this),
unityFileSystemInit: this.unityFileSystemInit.bind(this),
tuanjieFileSystemInit: this.unityFileSystemInit.bind(this),
processRawData: Gn.processRawData,
preRun: [],
postRun: [],
print: function (e) {
console.log(e);
},
printErr: this.printErr.bind(this),
Jobs: {},
canvas: p,
buildDownloadProgress: {},
resolveBuildUrl: ln,
streamingAssetsUrl: function () {
return ln("StreamingAssets");
},
pthreadMainPrefixURL: "Build/",
webglContextAttributes: {
premultipliedAlpha: 1,
preserveDrawingBuffer: 1,
},
},
SetFullscreen: function () {
for (
var t, n = arguments.length, i = new Array(n), a = 0;
a < n;
a++
)
i[a] = arguments[a];
if (e.gameInstance.Module.SetFullscreen)
return (t =
e.gameInstance.Module.SetFullscreen).apply.apply(
t,
[e.gameInstance.Module].concat(i)
);
},
SendMessage: function () {
for (
var t, n = arguments.length, i = new Array(n), a = 0;
a < n;
a++
)
i[a] = arguments[a];
if (e.gameInstance.Module.SendMessage)
return (t =
e.gameInstance.Module.SendMessage).apply.apply(
t,
[e.gameInstance.Module].concat(i)
);
},
}),
(this.unityManager.gameInstance = this.gameInstance);
},
},
]),
i
);
})(ce).getInstance(),
ea = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "reportEmptyContent",
value: function (e) {
if ((0, _.xb)(e))
return ze.pluginError(
"[wxAssetBundle report]: invalid params"
);
var t = new kt({
ReportType: Ee.WxABReadEmptyContent,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify(e),
});
Rt.send(t);
},
},
{
key: "bindFunction",
value: function () {
this.unityManager.reporter.wxAssetBundle = {
reportEmptyContent: this.reportEmptyContent.bind(this),
};
},
},
]),
n
);
})(Wi).getInstance(),
ta = f(865).default,
na = [],
ia = (function (e) {
a(n, e);
var t = r(n);
function n(e, i) {
var a, r, o;
return (
u(this, n),
((a = t.call(this)).id = (0, _.hQ)(10, !0)),
(a.GLctx = i),
(na[a.id] =
null === (o = (r = ta.env.pluginEnv).createWKVideo) ||
void 0 === o
? void 0
: o.call(r)),
na[a.id]
? ((na[a.id].style.display = "none"),
(na[a.id].src = e),
(na[a.id].muted = !0),
na[a.id].setAttribute("muted", ""),
na[a.id].setAttribute("playsinline", ""),
(na[a.id].crossOrigin = "anonymous"),
(na[a.id].onseeked = function () {
a.emit("seek");
}),
(na[a.id].oncanplay = function () {
a.emit("canplay");
}),
(na[a.id].onerror = function (e) {
var t, n, i;
"string" == typeof e
? a.emit("error", e)
: a.emit(
"error",
null !==
(i =
null ===
(n =
null === (t = e.target) || void 0 === t
? void 0
: t.error) || void 0 === n
? void 0
: n.code) && void 0 !== i
? i
: ""
);
}))
: console.error("创建失败,基础库不支持或尚未初始化完"),
a
);
}
return (
c(n, [
{
key: "render",
value: function () {
if (this.GLctx && na[this.id]) {
var e = this.GLctx.RGBA,
t = this.GLctx.RGBA;
this.GLctx.texImage2D(
this.GLctx.TEXTURE_2D,
0,
e,
t,
this.GLctx.UNSIGNED_BYTE,
na[this.id]
);
}
},
},
{
key: "seek",
value: function (e) {
(this.lastSeenPlaybackTime = e),
na[this.id] && (na[this.id].currentTime = e);
},
},
{
key: "play",
value: function () {
var e;
return null === (e = na[this.id]) || void 0 === e
? void 0
: e.play();
},
},
{
key: "pause",
value: function () {
var e;
return null === (e = na[this.id]) || void 0 === e
? void 0
: e.pause();
},
},
{
key: "isReady",
get: function () {
return (
!!na[this.id] &&
(!this.ready &&
na[this.id].readyState >= na[this.id].HAVE_METADATA &&
(this.ready = !0),
!!this.ready)
);
},
},
{
key: "isPlaying",
get: function () {
return (
!!na[this.id] &&
this.isReady &&
!na[this.id].paused &&
!na[this.id].ended
);
},
},
{
key: "videoWidth",
get: function () {
var e, t;
return null !==
(t =
null === (e = na[this.id]) || void 0 === e
? void 0
: e.videoWidth) && void 0 !== t
? t
: 0;
},
},
{
key: "videoHeight",
get: function () {
var e, t;
return null !==
(t =
null === (e = na[this.id]) || void 0 === e
? void 0
: e.videoHeight) && void 0 !== t
? t
: 0;
},
},
{
key: "duration",
get: function () {
var e, t;
return null !==
(t =
null === (e = na[this.id]) || void 0 === e
? void 0
: e.duration) && void 0 !== t
? t
: 0;
},
},
{
key: "currentTime",
get: function () {
var e, t;
return null !==
(t =
null === (e = na[this.id]) || void 0 === e
? void 0
: e.currentTime) && void 0 !== t
? t
: 0;
},
},
{
key: "volume",
set: function (e) {
na[this.id] && (na[this.id].volume = e);
},
},
{
key: "playbackRate",
get: function () {
return na[this.id].playbackRate;
},
set: function (e) {
na[this.id] && (na[this.id].playbackRate = e);
},
},
{
key: "muted",
set: function (e) {
na[this.id] && (na[this.id].muted = e);
},
},
{
key: "loop",
get: function () {
var e, t;
return (
null !==
(t =
null === (e = na[this.id]) || void 0 === e
? void 0
: e.loop) &&
void 0 !== t &&
t
);
},
set: function (e) {
na[this.id] && (na[this.id].loop = e);
},
},
{
key: "onended",
set: function (e) {
na[this.id] && (na[this.id].onended = e);
},
},
{
key: "destroy",
value: function () {
this.loopEndPollInterval &&
clearInterval(this.loopEndPollInterval),
delete this.onendedCallback,
na[this.id] &&
((na[this.id].src = ""),
(na[this.id].onended = null),
(na[this.id].onerror = null),
(na[this.id].oncanplay = null),
(na[this.id].onseeked = null)),
(na[this.id] = null),
delete na[this.id];
},
},
]),
n
);
})(He()),
aa = (function (e) {
a(n, e);
var t = r(n);
function n() {
return u(this, n), t.apply(this, arguments);
}
return (
c(n, [
{
key: "init",
value: function (e) {
e.createWKVideo = function (e, t) {
return new ia(e, t);
};
},
},
]),
n
);
})(ce),
ra = f(865).default,
oa = function (e, t, n, i) {
return new (n || (n = Promise))(function (a, r) {
function o(e) {
try {
u(i.next(e));
} catch (e) {
r(e);
}
}
function s(e) {
try {
u(i.throw(e));
} catch (e) {
r(e);
}
}
function u(e) {
var t;
e.done
? a(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(o, s);
}
u((i = i.apply(e, t || [])).next());
});
},
sa = function (e, t) {
var n = {};
for (var i in e)
Object.prototype.hasOwnProperty.call(e, i) &&
t.indexOf(i) < 0 &&
(n[i] = e[i]);
if (null != e && "function" == typeof Object.getOwnPropertySymbols) {
var a = 0;
for (i = Object.getOwnPropertySymbols(e); a < i.length; a++)
t.indexOf(i[a]) < 0 &&
Object.prototype.propertyIsEnumerable.call(e, i[a]) &&
(n[i[a]] = e[i[a]]);
}
return n;
},
ua = (function () {
function e() {
var t = this,
i =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {};
u(this, e);
var a = i.videoManager,
r = i.finalPageVideoUrl,
o = i.pageManager,
c = i.loadingPageConfig,
l = i.useCoverView,
f = i.preloadDataList,
g = i.loadDataPackageFromSubpackage,
p = void 0 !== g && g,
m = i.compressDataPackage,
v = void 0 !== m && m,
y = sa(i, [
"videoManager",
"finalPageVideoUrl",
"pageManager",
"loadingPageConfig",
"useCoverView",
"preloadDataList",
"loadDataPackageFromSubpackage",
"compressDataPackage",
]);
(this.font = {}),
(this.wasmsplit = {}),
(this.reporter = {}),
(this.useCoverView = !0),
(this.PLUGIN_CACHE_PATH = me),
(this.hideAfterCallmain = !1),
(this.contextType = 1),
(this.TimeLogger = Ge),
(this.Logger = ze),
(this.launchData = []),
(this.getFeatureFlags = oa(
t,
void 0,
void 0,
n().mark(function e() {
var t, i, a;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (ra.env.isMiniGamePlugin) {
e.next = 2;
break;
}
return e.abrupt(
"return",
(ze.pluginLog("非插件模式跳过特性开关逻辑"),
Promise.resolve())
);
case 2:
return (
(t = h.getLaunchOptionsSync()),
(i = t.scene),
(a = !1),
e.abrupt(
"return",
(setTimeout(function () {
a ||
(ze.eventLog("特性开关拉取超时,使用默认值"),
(a = !0));
}, 500),
ra.network
.gameTransfer({
url: "unity.queryfeatureflags",
flat: !0,
data: {
platform: N.platform,
system: N.system,
sdk_version: N.SDKVersion,
unity_version: d.unityVersion,
plugin_version: L,
scene: i,
runtime: A.isWK ? Re.WK : Re.Normal,
asset_load_type:
Gn.loadDataPackageFromSubpackage
? Me.Subpackage
: Me.Cdn,
use_wasm_split: this.codeType,
version: N.version,
},
})
.then(function (e) {
var t,
n = s(e, 1)[0];
a ||
((a = !0),
(null ===
(t =
null == n ? void 0 : n.feature_list) ||
void 0 === t
? void 0
: t.length) && Ue.init(n.feature_list));
})
.catch(function (e) {
return (
ze.pluginLog("特性开关拉取失败", e),
Promise.resolve()
);
}))
)
);
case 5:
case "end":
return e.stop();
}
},
e,
this
);
})
)),
(this.initReporterPromise = oa(
t,
void 0,
void 0,
n().mark(function e() {
var t, i, a, r, o, s, u, c, l, f, g, p, m, v, y, S, T, b, w, C;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
Ge.timeStart("fileSystemInit"),
(e.next = 3),
wn.fileSystem.firstInitPromise
);
case 3:
return (
Ge.storeTime("fileSystemInit"),
(e.next = 6),
this.getFeatureFlags
);
case 6:
(t = h.getLaunchOptionsSync()),
(i = t.scene),
(a = t.query),
ze.eventLog("".concat(Yi.getAssetsLoadText())),
(r = (function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {};
return {
adSpaceType: Di(e[Le.AdSpaceType]),
adType: Di(e[Le.AdType]),
materialType: Di(e[Le.MaterialType]),
};
})(a)),
(o = r.adSpaceType),
(s = r.adType),
(u = r.materialType),
(c = Ue.getFeatureString()),
(f = (l = d).WASM_SPLIT_PLUGIN_VERSION),
(g = l.CODE_FILE_MD5),
(p = l.WASM_SPLIT_SUB_VERSION),
(m = l.WASM_SPLIT_API_VERSION),
(v = l.unityVersion),
(y = l.usedTextureCompression),
(S = l.usedAutoStreaming),
ze.eventLog("插件信息: ", {
pluginVersion: L,
unityVersion: v,
loadDataPackageFromSubpackage:
Gn.loadDataPackageFromSubpackage,
adSpaceType: o,
adType: s,
materialType: u,
abTest: c,
maxAllowSize: Se,
canUseCommonPackage: re,
subVersion: p,
codeMd5: g,
wasmSplitPluginVersion: f,
useWasmSplit: this.codeType === Pe.codeSplit,
canUseHighPerformance: J,
assetsLoadType: Yi.assetsLoadType,
usedTextureCompression: y,
usedAutoStreaming: S,
instanceId: k,
}),
X ||
(J &&
this.codeType !== Pe.codeSplit &&
ze.pluginError(
"[开发阶段提示 不影响线上版本]高性能模式下不使用代码分包会严重影响性能, 请阅读高性能模式文档: \nhttps://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/iOSOptimization.md"
)),
(T = new kt({
IsDownloadCode: Yi.assetsLoadType,
LoadingPageType: this.loadingPageType,
Scene: i,
BenchmarkLevel: B,
CodeType: this.codeType,
DataPackageLoadType:
Gn.loadDataPackageFromSubpackage
? Me.Subpackage
: Me.Cdn,
AdSpaceType: o,
AdType: s,
MaterialType: u,
ABTest: c,
})),
Pt.setBase(T),
Rt.setBase(T),
At.setBase(T),
Qe.triggerEvent(Ve.PluginLaunch, Ke(Xe, this)),
this.triggerLaunchProgress(Te.GAME_LAUNCH, 0),
(b = [
new kt({
ReportType: Te.GAME_LAUNCH,
CostTimeMs: 0,
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({
canUseCommonPackage: re,
wasmSplitPluginVersion: f,
codeMd5: g,
wasmSplitSubVersion: p,
wasmSplitApiVersion: m,
usedTextureCompression: y,
usedAutoStreaming: S,
}),
}),
]),
(w = Ge.popTime("fileSystemInit")),
(C = Ge.popTime("getContext")),
w &&
b.push(
new kt({
ReportType: Te.FILE_SYSTEM_INIT,
CostTimeMs: w.CostTimeMs,
RunTimeMs: w.RunTimeMs,
})
),
C &&
b.push(
new kt({
ReportType: Te.GET_CONTEXT,
CostTimeMs: C.CostTimeMs,
RunTimeMs: C.RunTimeMs,
})
),
wn.fileSystem.checkNeedReportStat(),
Pt.send(b),
h.onHide(this.onHide),
h.onShow(this.onShow);
case 14:
case "end":
return e.stop();
}
},
e,
this
);
})
)),
(this.loadingPage = null),
(this.launchStage = null),
(this.setPreloadList = ri.setPreloadList),
(this.codeType = 0),
(this.mainCalled = !1),
(this.loadingCount = 2),
(this.gameStarted = !1),
(this.showAbort = function () {
ne
? Li.getInstance()
: h.showModal({
title: "程序遇到错误",
content:
'可尝试重启游戏\n或通过"右上角菜单-反馈与投诉"提交功能异常反馈',
showCancel: !1,
confirmText: h.restartMiniProgram ? "重启游戏" : "确定",
success: function () {
h.restartMiniProgram && h.restartMiniProgram({});
},
});
}),
(this.printErr = function (n) {
if (t.needPluginReport() && !et(n)) {
Rt.send(
new kt({
ReportType: mt() || e.getCurrentStage(!0),
ErrorMsg: "".concat(n).slice(0, 1024),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({ mainCalled: t.mainCalled }),
})
);
var i = "string" == typeof n ? n : n.message;
se.warn(i), ue.error(i);
}
if (null == t ? void 0 : t.onLogError) {
var a = "string" == typeof n ? n : n.message;
t.onLogError(a);
}
console.error(n);
}),
(this.needPluginReport = function () {
var e = Ge.getRuntime(),
n = (
t.launchData.find(function (e) {
return e.type === Te.PREPARE_GAME;
}) || {}
).data,
i = (null == n ? void 0 : n.runTimeMs) || 0,
a = t.gameStarted && e - i < 500 && e < 6e4,
r = !t.gameStarted && e < 6e4;
return a || r;
}),
(this.reportScene = function (e) {
tt(e.sceneId) &&
e.sceneId < 1e3 &&
ze.pluginError("[reportScene]请检查sceneId"),
t.baseReportScene(e);
}),
(this.baseReportScene = function (e) {
ae && h.reportScene(e);
}),
(this.reportPluginLaunchScene = function (e, n) {
var i = {
sceneId: e,
costTime: n,
dimension: {
useCodeSplit: t.codeType ? St.True : St.False,
needDownloadDataPackage:
Yi.assetsLoadType !== de.AllCached ? St.True : St.False,
},
};
e === Te.PREPARE_GAME &&
(i.metric = { preloadedSize: String(ri.loadedSize) }),
t.baseReportScene(i);
}),
(this.reportCustomLaunchInfo = function () {
var e;
if (!t.gameStarted) {
ti.showResult(!0), (t.gameStarted = !0);
var n = Ge.timeEnd("游戏主场景耗时");
Pt.send(
new kt({
ReportType: Te.GAME_START,
CostTimeMs: n,
RunTimeMs: Ge.getRuntime(),
})
),
t.reportPluginLaunchScene(Te.GAME_START, n),
ze.eventLog(
"游戏可交互cost="
.concat(n, "ms,runtime=")
.concat(Ge.getRuntime())
),
A.isWK ||
null === (e = null == d ? void 0 : d.compileSubWasm) ||
void 0 === e ||
e.call(d);
}
}),
(this.setGameStage = function (e) {
pt(e);
}),
(this.reportGameStageCostTime = function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0,
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: "";
mt() &&
Pt.send(
new kt({
ReportType: mt(),
CostTimeMs: Number(e),
RunTimeMs: Ge.getRuntime(),
ExternInfo: t,
})
);
}),
(this.reportGameStageError = function () {
var e =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: 0,
t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: "",
n =
arguments.length > 2 && void 0 !== arguments[2]
? arguments[2]
: "";
mt() &&
vt(Number(e)) &&
Rt.send(
new kt({
ReportType: mt(),
ErrorMsg: String(t).slice(0, 1024),
RunTimeMs: Ge.getRuntime(),
ExternInfo: n,
ErrorType: Number(e),
})
);
}),
(this.reportGameSceneError = function (e) {
var t =
arguments.length > 1 && void 0 !== arguments[1]
? arguments[1]
: 0,
n =
arguments.length > 2 && void 0 !== arguments[2]
? arguments[2]
: "",
i =
arguments.length > 3 && void 0 !== arguments[3]
? arguments[3]
: "";
vt(Number(t)) &&
Rt.send(
new kt({
ReportType: e,
ErrorMsg: String(n).slice(0, 1024),
RunTimeMs: Ge.getRuntime(),
ExternInfo: i,
ErrorType: Number(t),
})
);
}),
(this.onHide = function () {
var t = "游戏切后台 showTimes:".concat(e.showTimes);
ze.pluginLog(t), ue.info(t);
var n = mt() || e.getCurrentStage();
n &&
At.send(
new kt({
StageType: String(n),
RunTimeMs: Ge.getRuntime(),
ExternInfo: JSON.stringify({ showTimes: e.showTimes }),
})
),
ht(!1);
}),
(this.onShow = function () {
e.showTimes += 1;
var t = "游戏切前台 showTimes:".concat(e.showTimes);
ze.pluginLog(t), ue.info(t), ht(!0);
}),
(this.setDataCDN = function (e) {
if (sn(e)) {
var t = e.endsWith("/") ? e : "".concat(e, "/");
(d.DATA_CDN = t), Qe.triggerEvent(Ve.ModulePrepared);
}
}),
Qe.init(this),
Ui.init(this),
qi.init(this),
ti.init(this),
Ki.init(this),
ea.init(this),
Gi.getInstance().init(this),
aa.getInstance().init(this),
this.init(
Object.assign(
{
videoManager: a,
finalPageVideoUrl: r,
pageManager: o,
preloadDataList: f,
loadingPageConfig: c,
useCoverView: l,
loadDataPackageFromSubpackage: p,
compressDataPackage: v,
},
y
)
),
Hi.init(this),
this.getFeatureFlags.then(function () {
Qe.triggerEvent(Ve.FeatureFlagReady, Ke(Xe, t)),
Sn.instance.init();
});
}
return (
c(
e,
[
{
key: "networkType",
get: function () {
return yt.networkType;
},
},
{
key: "isVisible",
get: function () {
return dt();
},
},
{
key: "isAssetsLoading",
get: function () {
return this.loadingCount > 0;
},
},
{
key: "getCachePath",
value: function (e) {
return wn.getCachePath(e);
},
},
{
key: "cleanAllCache",
value: function () {
return wn.cleanAllCache();
},
},
{
key: "cleanCache",
value: function (e) {
return wn.fileSystem.releaseMemory(e, 0);
},
},
{
key: "removeFile",
value: function (e) {
return wn.fileSystem.removeFile(e, !0);
},
},
{
key: "writeFile",
value: function (e, t) {
return wn.writeFile(e, t);
},
},
{
key: "writeLog",
value: function (e) {
e && (ze.eventLog("writeLog: ", e), se.log(e));
},
},
{
key: "writeWarn",
value: function (e) {
e && (ze.pluginWarn("writeWarn: ", e), se.warn(e));
},
},
{
key: "reportJump",
value: function () {
this.loadingPageType === le.INTERACTIVE_VIDEO &&
At.send(
new kt({
ActionType: 1,
PositionID: 1,
ActionID: 2,
RunTimeMs: Ge.getRuntime(),
})
);
},
},
{
key: "setConcurrent",
value: function (e) {
var t;
null === (t = null == ri ? void 0 : ri.setConcurrent) ||
void 0 === t ||
t.call(ri, e);
},
},
{
key: "initLoadingPage",
value: function () {
var e,
t =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {},
n = t.loadingPageConfig;
if (
((this.loadingPageType = le.LONG_VIDEO),
this.useCoverView &&
n &&
(A.isMiniGamePlugin &&
(this.loadingPageType = le.COVER_VIEW),
(d.isLoopRunnerEnable = !0)),
this.loadingPageType === le.LONG_VIDEO &&
((this.loadingPage = new ni({
src:
null ===
(e = null == n ? void 0 : n.materialConfig) ||
void 0 === e
? void 0
: e.backgroundVideo,
})),
(d.isLoopRunnerEnable = !0)),
this.loadingPageType === le.COVER_VIEW)
) {
var i = n || {},
a = i.totalLaunchTime,
r = i.scaleMode,
o = i.designWidth,
s = i.designHeight,
u = i.textConfig,
c = i.barConfig,
l = i.materialConfig,
h = i.iconConfig,
f = i.extensionButton,
g = i.visible;
this.loadingPage = new ki({
totalLaunchTime: a,
designWidth: o,
designHeight: s,
needDownload: Yi.needDownload,
hideAfterCallmain: this.hideAfterCallmain,
textConfig: u,
barConfig: c,
materialConfig: l,
scaleMode: r,
iconConfig: h,
extensionButton: f,
visible: g,
});
}
},
},
{
key: "initGameGlobal",
value: function () {
var e = this,
t =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {};
Object.entries(t).forEach(function (e) {
var t = s(e, 2),
n = t[0],
i = t[1];
if (
["STREAMING_CDN", "DATA_CDN"].includes(n) &&
i.includes("http")
) {
var a = i.endsWith("/") ? i : "".concat(i, "/");
d[n] = a;
} else d[n] = i;
}),
(d.UnityLoader = {
SystemInfo: {
width: V,
height: G,
gpu: (function () {
var t = p.getContext(_e[e.contextType]);
if (t) {
var n = t.getExtension("WEBGL_debug_renderer_info");
if (n)
return t.getParameter(n.UNMASKED_RENDERER_WEBGL);
}
return "unknown";
})(),
browser: "wx",
browserVersion: "0.0",
language:
d.navigator.userLanguage || d.navigator.language,
hasWebGL: this.contextType,
},
UnityCache: { XMLHttpRequest: ci },
});
},
},
{
key: "startGame",
value: function () {
return oa(
this,
void 0,
void 0,
n().mark(function e() {
var t = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
this.mainCalled ||
(this.clearViewPort(),
this.showLoadingPage()
.then(function () {
return oa(
t,
void 0,
void 0,
n().mark(function e() {
var t,
i = this;
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
return (
Qe.triggerEvent(
Ve.LoadingPageReady,
Ke(Xe, this)
),
(e.next = 3),
this.initReporterPromise
);
case 3:
return (
this.prepareModule(),
this.startCheckIs32Wechat(),
Ni.updateCodeType(
this.codeType ===
Pe.codeSplit
),
(t = [
Zi.loadWasmCode(),
Gn.loadDataPackage(),
]),
e.abrupt(
"return",
(this.codeType !==
Pe.codeSplit ||
(!ie &&
Ue.get(Oe) ===
Fe.open) ||
(ze.eventLog(
"禁用代码分包功能"
),
(this.parallelFetchSubWasmTask =
Zi.parallelFetchSubWasm()),
t.push(
this
.parallelFetchSubWasmTask
)),
Qe.triggerEvent(
Ve.ParallelLoading,
Ke(Xe, this)
),
Promise.all(t).then(
function () {
Qe.triggerEvent(
Ve.ParallelLoaded,
Ke(Xe, i)
),
ri.load(),
i.loadingPageType ===
le.COVER_VIEW &&
i.loadingPage.completeDownloadAnimation(),
Yi.needDownload
? i.start()
: setTimeout(
function () {
i.start();
},
100
);
}
))
)
);
case 8:
case "end":
return e.stop();
}
},
e,
this
);
})
);
})
.catch(function (e) {
ze.pluginError("start game fail: ", e);
}));
case 1:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "startCheckIs32Wechat",
value: function () {
var e = this;
N.abi &&
!N.abi.includes("64") &&
setTimeout(function () {
e.mainCalled ||
(ze.pluginError("当前是32位微信,请升级最新版本"),
h.showModal({
title: "提示",
content: "当前微信为32位版本\n请升级最新版本",
showCancel: !1,
confirmText: "确认升级",
success: function () {
h.updateWeChatApp();
},
}));
}, 3e4);
},
},
{
key: "clearViewPort",
value: function () {
var e = d.globalGL;
e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT);
},
},
{
key: "showLoadingPage",
value: function () {
var e = this;
return new Promise(function (t) {
e.loadingPageType === le.COVER_VIEW
? (e.loadingPage.load().then(function () {
e.loadingPage.show(),
e.loadingPage.startDownloadAnimation();
}),
t())
: (e.loadingPage.showLoadingPage(), t());
});
},
},
{
key: "resumeLoadingPage",
value: function () {
this.loadingPage.isVisible = !0;
},
},
{
key: "showFinalPage",
value: function () {
this.loadingPageType === le.INTERACTIVE_VIDEO &&
this.loadingPage.showFinalPage(this.mainCalled);
},
},
{
key: "hideFinalPage",
value: function () {
this.loadingPageType === le.INTERACTIVE_VIDEO &&
this.loadingPage.hideFinalPage();
},
},
{
key: "hideLoadingPage",
value: function () {
var e = this;
setTimeout(function () {
e.loadingPageType === le.LONG_VIDEO &&
(e.launchStage.hideProgress(),
e.loadingPage.hideLoadingPage()),
e.loadingPageType === le.COVER_VIEW &&
e.loadingPage.complete();
}, 0);
},
},
{
key: "prepareModule",
value: function () {
(this.gameInstance.Module.gameInstance = this.gameInstance),
(this.gameInstance.popup = function (e, t) {
return d.UnityLoader.Error.popup(this.gameInstance, e, t);
}),
(d.Module = this.gameInstance.Module);
},
},
{
key: "start",
value: function () {
return oa(
this,
void 0,
void 0,
n().mark(function e() {
return n().wrap(
function (e) {
for (;;)
switch ((e.prev = e.next)) {
case 0:
if (
((e.t0 =
this.loadingPageType === le.COVER_VIEW),
!e.t0)
) {
e.next = 5;
break;
}
return (
ze.eventLog(
"[coverview] start compile animation"
),
(e.next = 5),
this.loadingPage.startCompileAnimation()
);
case 5:
this.doStart();
case 6:
case "end":
return e.stop();
}
},
e,
this
);
})
);
},
},
{
key: "triggerLaunchProgress",
value: function (e, t) {
var n = Ke(Ze, this, e, t);
this.reportPluginLaunchScene(e, t),
this.launchData.push(n),
Qe.triggerEvent(Ve.LaunchProgress, n);
},
},
{
key: "init",
value: function () {
var t =
arguments.length > 0 && void 0 !== arguments[0]
? arguments[0]
: {},
n = t.videoManager,
i = t.finalPageVideoUrl,
a = t.pageManager,
r = t.loadingPageConfig,
o = (t.useCoverView, t.hideAfterCallmain),
s = t.preloadDataList,
u = t.loadDataPackageFromSubpackage,
c = void 0 !== u && u,
l = t.compressDataPackage,
f = void 0 !== l && l,
g = t.contextConfig,
m = void 0 === g ? {} : g,
v = sa(t, [
"videoManager",
"finalPageVideoUrl",
"pageManager",
"loadingPageConfig",
"useCoverView",
"hideAfterCallmain",
"preloadDataList",
"loadDataPackageFromSubpackage",
"compressDataPackage",
"contextConfig",
]);
if (!e.instance) {
if (
((this.gameInstance = null),
(this.mainCalled = !1),
(this.gameStarted = !1),
(this.useCoverView = ne),
(this.hideAfterCallmain = !!o),
(this.contextType = m.contextType || 1),
(this.codeType = d.useWasmCodeSplit
? Pe.codeSplit
: Pe.normal),
Ge.timeStart("getContext"),
(d.globalGL = p.getContext(_e[this.contextType], {
alpha: !0,
stencil: !0,
antialias: !1,
powerPreference: "high-performance",
})),
Ge.storeTime("getContext"),
!d.globalGL)
) {
var y = "不支持"
.concat(_e[this.contextType], ", 请升级")
.concat(A.isIOS ? "系统" : "微信");
return (
ze.pluginError(y),
void h.showModal({ title: "提示", content: y })
);
}
this.initGameGlobal(v),
$i.init(this),
Gn.init(this, {
loadDataPackageFromSubpackage: c,
compressDataPackage: f,
}),
Zi.init(this),
Yi.init(this),
s && ri.init({ preloadList: s }),
this.initLoadingPage({
videoManager: n,
pageManager: a,
loadingPageConfig: r,
finalPageVideoUrl: i,
}),
(this.launchStage = new _n(this.useCoverView)),
(e.instance = this);
}
},
},
{
key: "doStart",
value: function () {
this.gameInstance.Module.processRawData(),
this.gameInstance.Module.removeRunDependency(
"wasm-preloadAssets"
);
},
},
],
[
{
key: "getInstance",
value: function () {
return e.instance;
},
},
{
key: "getCurrentStage",
value: function () {
var e =
arguments.length > 0 &&
void 0 !== arguments[0] &&
arguments[0],
t = Object.values(_n.launchProgress).filter(function (e) {
return e.status === Ln.PENDING;
});
if (!e)
return t
.map(function (e) {
return e.stage;
})
.join("&");
if (!t.length) return Te.GAME_START;
var n = t.sort(function (e, t) {
return t.priority - e.priority;
}),
i = s(n, 1),
a = i[0];
return Te[a.stage];
},
},
]
),
e
);
})();
ua.showTimes = -1;
var ca = ua;
})(),
(module.exports = g);
})();