380 lines
16 KiB
JavaScript
380 lines
16 KiB
JavaScript
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
||
function getDefaultExportFromCjs(_) {
|
||
return _ && _.__esModule && Object.prototype.hasOwnProperty.call(_, "default") ? _.default : _;
|
||
}
|
||
var dayjs_min = { exports: {} };
|
||
(function(_, S) {
|
||
(function(L, O) {
|
||
_.exports = O();
|
||
})(commonjsGlobal, function() {
|
||
var L = 1e3, O = 6e4, C = 36e5, w = "millisecond", y = "second", v = "minute", m = "hour", D = "day", b = "week", f = "month", d = "quarter", u = "year", h = "date", c = "Invalid Date", I = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, Z = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, V = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(s) {
|
||
var n = ["th", "st", "nd", "rd"], e = s % 100;
|
||
return "[" + s + (n[(e - 20) % 10] || n[e] || n[0]) + "]";
|
||
} }, G = function(s, n, e) {
|
||
var r = String(s);
|
||
return !r || r.length >= n ? s : "" + Array(n + 1 - r.length).join(e) + s;
|
||
}, K = { s: G, z: function(s) {
|
||
var n = -s.utcOffset(), e = Math.abs(n), r = Math.floor(e / 60), t = e % 60;
|
||
return (n <= 0 ? "+" : "-") + G(r, 2, "0") + ":" + G(t, 2, "0");
|
||
}, m: function s(n, e) {
|
||
if (n.date() < e.date()) return -s(e, n);
|
||
var r = 12 * (e.year() - n.year()) + (e.month() - n.month()), t = n.clone().add(r, f), i = e - t < 0, o = n.clone().add(r + (i ? -1 : 1), f);
|
||
return +(-(r + (e - t) / (i ? t - o : o - t)) || 0);
|
||
}, a: function(s) {
|
||
return s < 0 ? Math.ceil(s) || 0 : Math.floor(s);
|
||
}, p: function(s) {
|
||
return { M: f, y: u, w: b, d: D, D: h, h: m, m: v, s: y, ms: w, Q: d }[s] || String(s || "").toLowerCase().replace(/s$/, "");
|
||
}, u: function(s) {
|
||
return s === void 0;
|
||
} }, P = "en", x = {};
|
||
x[P] = V;
|
||
var Q = "$isDayjsObject", N = function(s) {
|
||
return s instanceof z || !(!s || !s[Q]);
|
||
}, U = function s(n, e, r) {
|
||
var t;
|
||
if (!n) return P;
|
||
if (typeof n == "string") {
|
||
var i = n.toLowerCase();
|
||
x[i] && (t = i), e && (x[i] = e, t = i);
|
||
var o = n.split("-");
|
||
if (!t && o.length > 1) return s(o[0]);
|
||
} else {
|
||
var l = n.name;
|
||
x[l] = n, t = l;
|
||
}
|
||
return !r && t && (P = t), t || !r && P;
|
||
}, p = function(s, n) {
|
||
if (N(s)) return s.clone();
|
||
var e = typeof n == "object" ? n : {};
|
||
return e.date = s, e.args = arguments, new z(e);
|
||
}, a = K;
|
||
a.l = U, a.i = N, a.w = function(s, n) {
|
||
return p(s, { locale: n.$L, utc: n.$u, x: n.$x, $offset: n.$offset });
|
||
};
|
||
var z = function() {
|
||
function s(e) {
|
||
this.$L = U(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[Q] = !0;
|
||
}
|
||
var n = s.prototype;
|
||
return n.parse = function(e) {
|
||
this.$d = function(r) {
|
||
var t = r.date, i = r.utc;
|
||
if (t === null) return /* @__PURE__ */ new Date(NaN);
|
||
if (a.u(t)) return /* @__PURE__ */ new Date();
|
||
if (t instanceof Date) return new Date(t);
|
||
if (typeof t == "string" && !/Z$/i.test(t)) {
|
||
var o = t.match(I);
|
||
if (o) {
|
||
var l = o[2] - 1 || 0, $ = (o[7] || "0").substring(0, 3);
|
||
return i ? new Date(Date.UTC(o[1], l, o[3] || 1, o[4] || 0, o[5] || 0, o[6] || 0, $)) : new Date(o[1], l, o[3] || 1, o[4] || 0, o[5] || 0, o[6] || 0, $);
|
||
}
|
||
}
|
||
return new Date(t);
|
||
}(e), this.init();
|
||
}, n.init = function() {
|
||
var e = this.$d;
|
||
this.$y = e.getFullYear(), this.$M = e.getMonth(), this.$D = e.getDate(), this.$W = e.getDay(), this.$H = e.getHours(), this.$m = e.getMinutes(), this.$s = e.getSeconds(), this.$ms = e.getMilliseconds();
|
||
}, n.$utils = function() {
|
||
return a;
|
||
}, n.isValid = function() {
|
||
return this.$d.toString() !== c;
|
||
}, n.isSame = function(e, r) {
|
||
var t = p(e);
|
||
return this.startOf(r) <= t && t <= this.endOf(r);
|
||
}, n.isAfter = function(e, r) {
|
||
return p(e) < this.startOf(r);
|
||
}, n.isBefore = function(e, r) {
|
||
return this.endOf(r) < p(e);
|
||
}, n.$g = function(e, r, t) {
|
||
return a.u(e) ? this[r] : this.set(t, e);
|
||
}, n.unix = function() {
|
||
return Math.floor(this.valueOf() / 1e3);
|
||
}, n.valueOf = function() {
|
||
return this.$d.getTime();
|
||
}, n.startOf = function(e, r) {
|
||
var t = this, i = !!a.u(r) || r, o = a.p(e), l = function(T, Y) {
|
||
var j = a.w(t.$u ? Date.UTC(t.$y, Y, T) : new Date(t.$y, Y, T), t);
|
||
return i ? j : j.endOf(D);
|
||
}, $ = function(T, Y) {
|
||
return a.w(t.toDate()[T].apply(t.toDate("s"), (i ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(Y)), t);
|
||
}, M = this.$W, g = this.$M, k = this.$D, W = "set" + (this.$u ? "UTC" : "");
|
||
switch (o) {
|
||
case u:
|
||
return i ? l(1, 0) : l(31, 11);
|
||
case f:
|
||
return i ? l(1, g) : l(0, g + 1);
|
||
case b:
|
||
var H = this.$locale().weekStart || 0, E = (M < H ? M + 7 : M) - H;
|
||
return l(i ? k - E : k + (6 - E), g);
|
||
case D:
|
||
case h:
|
||
return $(W + "Hours", 0);
|
||
case m:
|
||
return $(W + "Minutes", 1);
|
||
case v:
|
||
return $(W + "Seconds", 2);
|
||
case y:
|
||
return $(W + "Milliseconds", 3);
|
||
default:
|
||
return this.clone();
|
||
}
|
||
}, n.endOf = function(e) {
|
||
return this.startOf(e, !1);
|
||
}, n.$set = function(e, r) {
|
||
var t, i = a.p(e), o = "set" + (this.$u ? "UTC" : ""), l = (t = {}, t[D] = o + "Date", t[h] = o + "Date", t[f] = o + "Month", t[u] = o + "FullYear", t[m] = o + "Hours", t[v] = o + "Minutes", t[y] = o + "Seconds", t[w] = o + "Milliseconds", t)[i], $ = i === D ? this.$D + (r - this.$W) : r;
|
||
if (i === f || i === u) {
|
||
var M = this.clone().set(h, 1);
|
||
M.$d[l]($), M.init(), this.$d = M.set(h, Math.min(this.$D, M.daysInMonth())).$d;
|
||
} else l && this.$d[l]($);
|
||
return this.init(), this;
|
||
}, n.set = function(e, r) {
|
||
return this.clone().$set(e, r);
|
||
}, n.get = function(e) {
|
||
return this[a.p(e)]();
|
||
}, n.add = function(e, r) {
|
||
var t, i = this;
|
||
e = Number(e);
|
||
var o = a.p(r), l = function(g) {
|
||
var k = p(i);
|
||
return a.w(k.date(k.date() + Math.round(g * e)), i);
|
||
};
|
||
if (o === f) return this.set(f, this.$M + e);
|
||
if (o === u) return this.set(u, this.$y + e);
|
||
if (o === D) return l(1);
|
||
if (o === b) return l(7);
|
||
var $ = (t = {}, t[v] = O, t[m] = C, t[y] = L, t)[o] || 1, M = this.$d.getTime() + e * $;
|
||
return a.w(M, this);
|
||
}, n.subtract = function(e, r) {
|
||
return this.add(-1 * e, r);
|
||
}, n.format = function(e) {
|
||
var r = this, t = this.$locale();
|
||
if (!this.isValid()) return t.invalidDate || c;
|
||
var i = e || "YYYY-MM-DDTHH:mm:ssZ", o = a.z(this), l = this.$H, $ = this.$m, M = this.$M, g = t.weekdays, k = t.months, W = t.meridiem, H = function(Y, j, A, F) {
|
||
return Y && (Y[j] || Y(r, i)) || A[j].slice(0, F);
|
||
}, E = function(Y) {
|
||
return a.s(l % 12 || 12, Y, "0");
|
||
}, T = W || function(Y, j, A) {
|
||
var F = Y < 12 ? "AM" : "PM";
|
||
return A ? F.toLowerCase() : F;
|
||
};
|
||
return i.replace(Z, function(Y, j) {
|
||
return j || function(A) {
|
||
switch (A) {
|
||
case "YY":
|
||
return String(r.$y).slice(-2);
|
||
case "YYYY":
|
||
return a.s(r.$y, 4, "0");
|
||
case "M":
|
||
return M + 1;
|
||
case "MM":
|
||
return a.s(M + 1, 2, "0");
|
||
case "MMM":
|
||
return H(t.monthsShort, M, k, 3);
|
||
case "MMMM":
|
||
return H(k, M);
|
||
case "D":
|
||
return r.$D;
|
||
case "DD":
|
||
return a.s(r.$D, 2, "0");
|
||
case "d":
|
||
return String(r.$W);
|
||
case "dd":
|
||
return H(t.weekdaysMin, r.$W, g, 2);
|
||
case "ddd":
|
||
return H(t.weekdaysShort, r.$W, g, 3);
|
||
case "dddd":
|
||
return g[r.$W];
|
||
case "H":
|
||
return String(l);
|
||
case "HH":
|
||
return a.s(l, 2, "0");
|
||
case "h":
|
||
return E(1);
|
||
case "hh":
|
||
return E(2);
|
||
case "a":
|
||
return T(l, $, !0);
|
||
case "A":
|
||
return T(l, $, !1);
|
||
case "m":
|
||
return String($);
|
||
case "mm":
|
||
return a.s($, 2, "0");
|
||
case "s":
|
||
return String(r.$s);
|
||
case "ss":
|
||
return a.s(r.$s, 2, "0");
|
||
case "SSS":
|
||
return a.s(r.$ms, 3, "0");
|
||
case "Z":
|
||
return o;
|
||
}
|
||
return null;
|
||
}(Y) || o.replace(":", "");
|
||
});
|
||
}, n.utcOffset = function() {
|
||
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
||
}, n.diff = function(e, r, t) {
|
||
var i, o = this, l = a.p(r), $ = p(e), M = ($.utcOffset() - this.utcOffset()) * O, g = this - $, k = function() {
|
||
return a.m(o, $);
|
||
};
|
||
switch (l) {
|
||
case u:
|
||
i = k() / 12;
|
||
break;
|
||
case f:
|
||
i = k();
|
||
break;
|
||
case d:
|
||
i = k() / 3;
|
||
break;
|
||
case b:
|
||
i = (g - M) / 6048e5;
|
||
break;
|
||
case D:
|
||
i = (g - M) / 864e5;
|
||
break;
|
||
case m:
|
||
i = g / C;
|
||
break;
|
||
case v:
|
||
i = g / O;
|
||
break;
|
||
case y:
|
||
i = g / L;
|
||
break;
|
||
default:
|
||
i = g;
|
||
}
|
||
return t ? i : a.a(i);
|
||
}, n.daysInMonth = function() {
|
||
return this.endOf(f).$D;
|
||
}, n.$locale = function() {
|
||
return x[this.$L];
|
||
}, n.locale = function(e, r) {
|
||
if (!e) return this.$L;
|
||
var t = this.clone(), i = U(e, r, !0);
|
||
return i && (t.$L = i), t;
|
||
}, n.clone = function() {
|
||
return a.w(this.$d, this);
|
||
}, n.toDate = function() {
|
||
return new Date(this.valueOf());
|
||
}, n.toJSON = function() {
|
||
return this.isValid() ? this.toISOString() : null;
|
||
}, n.toISOString = function() {
|
||
return this.$d.toISOString();
|
||
}, n.toString = function() {
|
||
return this.$d.toUTCString();
|
||
}, s;
|
||
}(), J = z.prototype;
|
||
return p.prototype = J, [["$ms", w], ["$s", y], ["$m", v], ["$H", m], ["$W", D], ["$M", f], ["$y", u], ["$D", h]].forEach(function(s) {
|
||
J[s[1]] = function(n) {
|
||
return this.$g(n, s[0], s[1]);
|
||
};
|
||
}), p.extend = function(s, n) {
|
||
return s.$i || (s(n, z, p), s.$i = !0), p;
|
||
}, p.locale = U, p.isDayjs = N, p.unix = function(s) {
|
||
return p(1e3 * s);
|
||
}, p.en = x[P], p.Ls = x, p.p = {}, p;
|
||
});
|
||
})(dayjs_min);
|
||
var dayjs_minExports = dayjs_min.exports;
|
||
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
||
var zhCn = { exports: {} };
|
||
(function(_, S) {
|
||
(function(L, O) {
|
||
_.exports = O(dayjs_minExports);
|
||
})(commonjsGlobal, function(L) {
|
||
function O(y) {
|
||
return y && typeof y == "object" && "default" in y ? y : { default: y };
|
||
}
|
||
var C = O(L), w = { name: "zh-cn", weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"), weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"), weekdaysMin: "日_一_二_三_四_五_六".split("_"), months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"), monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"), ordinal: function(y, v) {
|
||
return v === "W" ? y + "周" : y + "日";
|
||
}, weekStart: 1, yearStart: 4, formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY年M月D日", LLL: "YYYY年M月D日Ah点mm分", LLLL: "YYYY年M月D日ddddAh点mm分", l: "YYYY/M/D", ll: "YYYY年M月D日", lll: "YYYY年M月D日 HH:mm", llll: "YYYY年M月D日dddd HH:mm" }, relativeTime: { future: "%s内", past: "%s前", s: "几秒", m: "1 分钟", mm: "%d 分钟", h: "1 小时", hh: "%d 小时", d: "1 天", dd: "%d 天", M: "1 个月", MM: "%d 个月", y: "1 年", yy: "%d 年" }, meridiem: function(y, v) {
|
||
var m = 100 * y + v;
|
||
return m < 600 ? "凌晨" : m < 900 ? "早上" : m < 1100 ? "上午" : m < 1300 ? "中午" : m < 1800 ? "下午" : "晚上";
|
||
} };
|
||
return C.default.locale(w, null, !0), w;
|
||
});
|
||
})(zhCn);
|
||
dayjs.locale("zh-cn");
|
||
const createWorkerSide = (_) => {
|
||
const S = {
|
||
msg_id: 0,
|
||
fn_id: 0,
|
||
mQueue: /* @__PURE__ */ new Map(),
|
||
fnStore: /* @__PURE__ */ new Map(),
|
||
mMethodWorkspace: /* @__PURE__ */ new Map()
|
||
};
|
||
return { Util: (w, y) => {
|
||
const v = (f) => {
|
||
if (typeof f != "function") return f;
|
||
const d = `fn_${S.fn_id++}`;
|
||
return S.fnStore.set(d, f), { __fn_id__: d };
|
||
}, m = (f, d, u) => {
|
||
const h = S.msg_id++;
|
||
return new Promise((c, I) => {
|
||
S.mQueue.set(h, [c, I]), _.postMessage({ id: h, task_id: w, session: y, category: "util", method: f, args: d.map(v), chain_id: u });
|
||
});
|
||
}, D = (f) => new Proxy(f, {
|
||
get(d, u) {
|
||
return typeof u == "symbol" ? d[u] : u in Promise.prototype ? (...h) => D(
|
||
d.then((c) => c && typeof c == "object" && c.__chain_id__ ? m(u, h, c.__chain_id__) : u === "then" ? typeof h[0] == "function" ? h[0](c) : c : (u === "finally" && typeof h[0] == "function" && h[0](), c)).catch((c) => u === "catch" ? typeof h[0] == "function" ? h[0](c) : Promise.reject(c) : u === "finally" ? (typeof h[0] == "function" && h[0](), Promise.reject(c)) : u === "then" && typeof h[1] == "function" ? h[1](c) : Promise.reject(c))
|
||
) : (...h) => D(
|
||
d.then((c) => {
|
||
if (!c || !c.__chain_id__) throw new Error(`${u} 不可链式调用`);
|
||
return m(u, h, c.__chain_id__);
|
||
})
|
||
);
|
||
}
|
||
}), b = (f) => new Proxy(
|
||
(...d) => D(m(f, d, null)),
|
||
{ get: (d, u) => typeof u == "symbol" ? void 0 : b(`${f}/${u}`) }
|
||
);
|
||
return new Proxy(() => {
|
||
}, {
|
||
// 函数调用形式:Util('ns')
|
||
apply: (f, d, [u]) => new Proxy({}, {
|
||
get: (h, c) => typeof c == "symbol" ? void 0 : b(u ? `${u}/${c}` : c)
|
||
}),
|
||
// 属性访问形式:Util.fn
|
||
get: (f, d) => typeof d == "symbol" ? void 0 : b(d)
|
||
});
|
||
}, state: S, onMessage: ({ data: { id: w, data: y, error: v, category: m, fn_id: D, cb_id: b, args: f } }) => {
|
||
if (m === "util") {
|
||
const d = S.mQueue.get(w);
|
||
if (!d) return;
|
||
S.mQueue.delete(w), v !== null ? d[1](v) : d[0](y);
|
||
} else if (m === "invoke_fn") {
|
||
const d = S.fnStore.get(D);
|
||
if (!d) {
|
||
_.postMessage({ category: "invoke_fn_result", cb_id: b, result: null, error: `fn_id '${D}' not found` });
|
||
return;
|
||
}
|
||
Promise.resolve(d(...f || [])).then((u) => {
|
||
_.postMessage({ category: "invoke_fn_result", cb_id: b, result: u, error: null });
|
||
}).catch((u) => {
|
||
_.postMessage({ category: "invoke_fn_result", cb_id: b, result: null, error: String(u) });
|
||
});
|
||
}
|
||
}, clearSession: (w) => {
|
||
S.mMethodWorkspace.delete(w);
|
||
} };
|
||
};
|
||
if (typeof self < "u" && (self !== globalThis || typeof DedicatedWorkerGlobalScope < "u" && self instanceof DedicatedWorkerGlobalScope)) {
|
||
const { Util, onMessage, clearSession } = createWorkerSide(self);
|
||
self.addEventListener("message", onMessage), self.addEventListener("message", ({ data: _ }) => {
|
||
_.category === "clear" && clearSession(_.session);
|
||
}), self.addEventListener("message", ({ data: { id, method, args, category, session } }) => {
|
||
if (category !== "eval") return;
|
||
const argsKeys = Object.keys(args || {}), fn = eval(`(async function({${argsKeys.join(", ")}}, Util){ ${method} })`);
|
||
Promise.resolve(fn.call({}, args || {}, Util(id, session))).then((_) => self.postMessage({ id, session, category, data: _, error: null })).catch((_) => {
|
||
const S = _ instanceof DOMException && _.name === "DataCloneError" ? "DataCloneError 返回结果只能为简单数据格式" : String(_);
|
||
self.postMessage({ id, session, category, data: null, error: S });
|
||
});
|
||
});
|
||
}
|
||
export {
|
||
createWorkerSide
|
||
};
|