@zyzgroup/core-web 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/zyzgroup_core_web.iife.js +12 -0
- package/dist/zyzgroup_core_web.iife.js.map +1 -0
- package/dist/zyzgroup_core_web.js +1250 -0
- package/dist/zyzgroup_core_web.js.map +1 -0
- package/dist/zyzgroup_core_web.umd.cjs +12 -0
- package/dist/zyzgroup_core_web.umd.cjs.map +1 -0
- package/package.json +6 -5
- package/types/Canvas2Image.d.ts +13 -0
- package/types/Canvas2Image.d.ts.map +1 -0
- package/types/DOMKeyboardKeyCode.d.ts +11 -0
- package/types/DOMKeyboardKeyCode.d.ts.map +1 -0
- package/types/canvas.d.ts +2 -0
- package/types/canvas.d.ts.map +1 -0
- package/types/cookie.d.ts +5 -0
- package/types/cookie.d.ts.map +1 -0
- package/types/dom.d.ts +20 -0
- package/types/dom.d.ts.map +1 -0
- package/types/env.d.ts +17 -0
- package/types/env.d.ts.map +1 -0
- package/types/error.d.ts +1 -0
- package/types/error.d.ts.map +1 -0
- package/types/fetch.d.ts +12 -0
- package/types/fetch.d.ts.map +1 -0
- package/types/file.d.ts +1 -0
- package/types/file.d.ts.map +1 -0
- package/types/image.d.ts +4 -0
- package/types/image.d.ts.map +1 -0
- package/types/index.d.ts +18 -0
- package/types/index.d.ts.map +1 -0
- package/types/microTask.d.ts +2 -0
- package/types/microTask.d.ts.map +1 -0
- package/types/mouse.d.ts +2 -0
- package/types/mouse.d.ts.map +1 -0
- package/types/onDocumentReady.d.ts +2 -0
- package/types/onDocumentReady.d.ts.map +1 -0
- package/types/patchDOM.d.ts +2 -0
- package/types/patchDOM.d.ts.map +1 -0
- package/types/position.d.ts +42 -0
- package/types/position.d.ts.map +1 -0
- package/types/rem.d.ts +2 -0
- package/types/rem.d.ts.map +1 -0
- package/types/theme.d.ts +2 -0
- package/types/theme.d.ts.map +1 -0
- package/types/url.d.ts +7 -0
- package/types/url.d.ts.map +1 -0
- package/types/websocket.d.ts +16 -0
- package/types/websocket.d.ts.map +1 -0
- package/dist/zyzgroup-core-web.js +0 -156
- package/dist/zyzgroup-core-web.js.map +0 -1
- package/dist/zyzgroup-core-web.umd.cjs +0 -2
- package/dist/zyzgroup-core-web.umd.cjs.map +0 -1
|
@@ -0,0 +1,1250 @@
|
|
|
1
|
+
class I extends Error {
|
|
2
|
+
cause;
|
|
3
|
+
constructor(t, n) {
|
|
4
|
+
super(t, n), this.name = this.constructor.name;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
class F extends I {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("This is not a browser environment");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class B extends I {
|
|
13
|
+
constructor() {
|
|
14
|
+
super("Cancel select");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class j extends I {
|
|
18
|
+
accepts;
|
|
19
|
+
constructor(t) {
|
|
20
|
+
super(`Please select files in ${t} format`), this.accepts = t;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function Y(e, t) {
|
|
24
|
+
e.addEventListener(
|
|
25
|
+
"change",
|
|
26
|
+
function() {
|
|
27
|
+
t(e.files);
|
|
28
|
+
},
|
|
29
|
+
!1
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function Q(e, t) {
|
|
33
|
+
e.addEventListener(
|
|
34
|
+
"dragover",
|
|
35
|
+
function(n) {
|
|
36
|
+
n.stopPropagation(), n.preventDefault(), n.dataTransfer && (n.dataTransfer.dropEffect = "copy");
|
|
37
|
+
},
|
|
38
|
+
!1
|
|
39
|
+
), e.addEventListener(
|
|
40
|
+
"drop",
|
|
41
|
+
function(n) {
|
|
42
|
+
n.stopPropagation(), n.preventDefault(), n.dataTransfer && t(n.dataTransfer.files);
|
|
43
|
+
},
|
|
44
|
+
!1
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const K = (e = ["*"], t) => {
|
|
48
|
+
if (!globalThis.document || !(globalThis.document instanceof Document))
|
|
49
|
+
throw new F();
|
|
50
|
+
const n = globalThis.document.createElement("input");
|
|
51
|
+
return n.setAttribute("type", "file"), n.setAttribute("visibility", "hidden"), Array.isArray(e) && e.length > 0 && n.setAttribute("accept", e.join(",")), t && n.setAttribute("multiple", "true"), n.click(), new Promise((r, l) => {
|
|
52
|
+
globalThis.addEventListener(
|
|
53
|
+
"focus",
|
|
54
|
+
() => {
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
(!n.files || n.files?.length === 0) && l(new B());
|
|
57
|
+
}, 1e3);
|
|
58
|
+
},
|
|
59
|
+
{ once: !0 }
|
|
60
|
+
), n.addEventListener("change", () => {
|
|
61
|
+
if (!n.files || n.files?.length === 0)
|
|
62
|
+
l(new B());
|
|
63
|
+
else {
|
|
64
|
+
const f = Array.from(n.files);
|
|
65
|
+
o(f) && l(new j(e)), r(f);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
function o(r) {
|
|
70
|
+
return !e.includes("*") && r.some((l) => !e.includes(`.${$(l)}`));
|
|
71
|
+
}
|
|
72
|
+
}, Z = (e) => {
|
|
73
|
+
const t = new FileReader();
|
|
74
|
+
return new Promise((n, o) => {
|
|
75
|
+
t.addEventListener(
|
|
76
|
+
"progress",
|
|
77
|
+
(r) => {
|
|
78
|
+
const l = "(" + Math.floor(r.total / 1e3) + " KB)", f = Math.floor(r.loaded / r.total * 100) + "%";
|
|
79
|
+
console.log(`Loading size: ${l} progress: ${f}`);
|
|
80
|
+
}
|
|
81
|
+
), t.addEventListener("load", (r) => {
|
|
82
|
+
n(r.target?.result);
|
|
83
|
+
}), t.addEventListener("error", (r) => {
|
|
84
|
+
o(r);
|
|
85
|
+
}), e(t);
|
|
86
|
+
});
|
|
87
|
+
}, $ = (e) => {
|
|
88
|
+
let t;
|
|
89
|
+
return e instanceof File ? t = e.name : t = e, t.match(/\.([0-9a-z]+)(?:[\\?#]|$)/i)[1] ?? "";
|
|
90
|
+
}, N = (e) => /^image\//.test(e.type), ee = (e) => /^video\//.test(e.type), te = (e) => /^audio\//.test(e.type), ne = (e) => /^application\/(?:vnd\.openxmlformats-officedocument\.wordprocessingml\.document|msword|vnd\.ms-word\.document\.macroenabled\.12|vnd\.openxmlformats-officedocument\.wordprocessingml\.template|vnd\.ms-word\.template\.macroenabled\.12)$/.test(
|
|
91
|
+
e.type
|
|
92
|
+
), oe = (e) => /^application\/(?:vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet|vnd\.ms-excel|vnd\.ms-excel\.sheet\.macroenabled\.12|vnd\.openxmlformats-officedocument\.spreadsheetml\.template|vnd\.ms-excel\.template\.macroenabled\.12)$/.test(
|
|
93
|
+
e.type
|
|
94
|
+
), re = (e) => /^application\/(?:vnd\.ms-powerpoint|vnd\.openxmlformats-officedocument\.presentationml\.presentation|vnd\.ms-powerpoint\.presentation\.macroenabled\.12|vnd\.openxmlformats-officedocument\.presentationml\.template|vnd\.ms-powerpoint\.template\.macroenabled\.12)$/.test(
|
|
95
|
+
e.type
|
|
96
|
+
), ie = (e) => /^application\/json$/.test(e.type), ae = (e) => /^(?:application|text)\/(?:xml|xhtml\+xml)$/.test(e.type);
|
|
97
|
+
function se(e) {
|
|
98
|
+
const t = e.slice(0, 4), n = new FileReader();
|
|
99
|
+
let o;
|
|
100
|
+
return new Promise((r, l) => {
|
|
101
|
+
n.onload = function() {
|
|
102
|
+
const f = n.result;
|
|
103
|
+
switch (new DataView(f).getUint32(0, !1)) {
|
|
104
|
+
case 2303741511:
|
|
105
|
+
o = "image/png";
|
|
106
|
+
break;
|
|
107
|
+
case 1195984440:
|
|
108
|
+
o = "image/gif";
|
|
109
|
+
break;
|
|
110
|
+
case 626017350:
|
|
111
|
+
o = "application/pdf";
|
|
112
|
+
break;
|
|
113
|
+
case 1347093252:
|
|
114
|
+
o = "application/zip";
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return r(o);
|
|
118
|
+
}, n.readAsArrayBuffer(t);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function ce(e) {
|
|
122
|
+
const t = new Blob(["(" + e.toString() + ")()"], {
|
|
123
|
+
type: "application/javascript"
|
|
124
|
+
});
|
|
125
|
+
return URL.createObjectURL(t);
|
|
126
|
+
}
|
|
127
|
+
function le(e, t) {
|
|
128
|
+
if (!e.type.startsWith("image/"))
|
|
129
|
+
return;
|
|
130
|
+
const n = document.createElement("img");
|
|
131
|
+
return n.src = URL.createObjectURL(e), n.width = t?.width ?? 60, n.height = t?.height ?? 60, n.onload = function() {
|
|
132
|
+
}, n;
|
|
133
|
+
}
|
|
134
|
+
function ue(e) {
|
|
135
|
+
function t() {
|
|
136
|
+
document.readyState !== "loading" && (e(), document.removeEventListener("DOMContentLoaded", t));
|
|
137
|
+
}
|
|
138
|
+
typeof window < "u" && typeof document < "u" && (document.addEventListener("DOMContentLoaded", t), t());
|
|
139
|
+
}
|
|
140
|
+
function de(e) {
|
|
141
|
+
typeof queueMicrotask == "function" ? queueMicrotask(e) : Promise.resolve().then(e).catch(
|
|
142
|
+
(t) => setTimeout(() => {
|
|
143
|
+
throw t;
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function z(e, t, n) {
|
|
148
|
+
if (!e) {
|
|
149
|
+
n && t && n.appendChild(t);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!e.isEqualNode(t)) {
|
|
153
|
+
if (e.nodeName !== t.nodeName) {
|
|
154
|
+
n.replaceChild(t, e);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
158
|
+
e.textContent !== t.textContent && (e.textContent = t.textContent);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
for (let o = e.attributes.length - 1; o >= 0; o--) {
|
|
162
|
+
const r = e.attributes[o].name;
|
|
163
|
+
!t.hasAttribute(r) && r !== "open" && e.removeAttribute(r);
|
|
164
|
+
}
|
|
165
|
+
for (let o = 0; o < t.attributes.length; o++) {
|
|
166
|
+
const r = t.attributes[o].name, l = t.attributes[o].value;
|
|
167
|
+
e.setAttribute(r, l);
|
|
168
|
+
}
|
|
169
|
+
for (let o = 0; o < t.childNodes.length; o++)
|
|
170
|
+
e.childNodes[o] ? z(
|
|
171
|
+
e.childNodes[o],
|
|
172
|
+
t.childNodes[o],
|
|
173
|
+
e
|
|
174
|
+
) : e.appendChild(t.childNodes[o].cloneNode(!0));
|
|
175
|
+
for (; e.childNodes.length > t.childNodes.length; )
|
|
176
|
+
e.lastChild && e.removeChild(e.lastChild);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function fe(e, t, n) {
|
|
180
|
+
var o = /* @__PURE__ */ new Date();
|
|
181
|
+
o.setTime(o.getTime() + n * 24 * 60 * 60 * 1e3);
|
|
182
|
+
var r = "expires=" + o.toGMTString();
|
|
183
|
+
document.cookie = e + "=" + t + "; " + r;
|
|
184
|
+
}
|
|
185
|
+
function me(e) {
|
|
186
|
+
for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {
|
|
187
|
+
var r = n[o].trim();
|
|
188
|
+
if (r.indexOf(t) == 0)
|
|
189
|
+
return r.substring(t.length, r.length);
|
|
190
|
+
}
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
const ge = () => document.cookie.split(";").map((e) => e.split("=")).reduce((e, [t, n]) => (e[t.trim().replace('"', "")] = n) && e, {}), pe = () => document.cookie.split(";").forEach(
|
|
194
|
+
(e) => document.cookie = e.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`)
|
|
195
|
+
);
|
|
196
|
+
class y {
|
|
197
|
+
constructor(t) {
|
|
198
|
+
this.waitingResponse = [], this.messageQueue = [], this.url = t, this.createSocket();
|
|
199
|
+
}
|
|
200
|
+
// The reconnection logic is that whenever a message fails to send, the
|
|
201
|
+
// message is added to messageQueue and a reconnection attempt is made.
|
|
202
|
+
// So, when a connection is lost, it is reconnected to after a certain
|
|
203
|
+
// time, but rather only when the user initiates an action that must
|
|
204
|
+
// message (i.e.) interact with the WebSocket
|
|
205
|
+
createSocket() {
|
|
206
|
+
this.socket = new y(this.url), this.socket.onopen = () => {
|
|
207
|
+
this.messageQueue.forEach((t) => this.socket.send(t)), this.messageQueue = [];
|
|
208
|
+
}, this.socket.onclose = (t) => {
|
|
209
|
+
const { code: n, reason: o, wasClean: r } = t;
|
|
210
|
+
console.log(`ws closed : ${n} ${o} ${r}`);
|
|
211
|
+
}, this.socket.onerror = (t) => {
|
|
212
|
+
console.log(`ws error : ${t}`);
|
|
213
|
+
}, this.socket.onmessage = (t) => {
|
|
214
|
+
this.processMessage(t);
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
// Creates a new socket and adds any unsent
|
|
218
|
+
// messages onto the message queue
|
|
219
|
+
recreateSocket(t) {
|
|
220
|
+
console.log("Reconnection Attempted"), this.messageQueue.push(t), this.createSocket();
|
|
221
|
+
}
|
|
222
|
+
// Closes a socket, which can take a bit
|
|
223
|
+
// of time (few seconds) since a roundtrip to
|
|
224
|
+
// the server is done
|
|
225
|
+
closeSocket() {
|
|
226
|
+
this.socket.close(), console.log("Socket closed manually.");
|
|
227
|
+
}
|
|
228
|
+
// Exposes a function for users to start a new
|
|
229
|
+
// socket - there is no way to 'reconnect' to
|
|
230
|
+
// a socket, a new websocket needs to be created
|
|
231
|
+
openSocket() {
|
|
232
|
+
this.createSocket(), console.log("Socket opened manually.");
|
|
233
|
+
}
|
|
234
|
+
async sendPayload(t) {
|
|
235
|
+
let n = +/* @__PURE__ */ new Date();
|
|
236
|
+
const o = this.waitingResponse[n] = { sent: n }, r = { ...o, ...t };
|
|
237
|
+
try {
|
|
238
|
+
this.socket.readyState === y.OPEN ? this.socket.send(JSON.stringify(r)) : this.recreateSocket(JSON.stringify(r));
|
|
239
|
+
const l = await new Promise(function(f, d) {
|
|
240
|
+
o.resolve = f, console.log(o), setTimeout(() => {
|
|
241
|
+
d("Timeout");
|
|
242
|
+
}, 5e3);
|
|
243
|
+
});
|
|
244
|
+
return console.info("Time took", (+/* @__PURE__ */ new Date() - o.sent) / 1e3), l;
|
|
245
|
+
} finally {
|
|
246
|
+
console.log("Exit code ran successfully"), delete this.waitingResponse[n];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Message Receiver, we attach this to the onmessage handler
|
|
250
|
+
// Expects message to be in JSON format, otherwise throws
|
|
251
|
+
// an error and simply logs the message to console
|
|
252
|
+
// The message must also have a requestid property (we
|
|
253
|
+
// use lowercase "i" here because Common Lisp's JZON library
|
|
254
|
+
// lowercases property names in JSON messages
|
|
255
|
+
// Test if the requestid passed in has an entry in the waitingResponse
|
|
256
|
+
// queue (data.requestid is the array index and the sendPayload function
|
|
257
|
+
// sets a value in this array for various id indexes to { sent: .. }
|
|
258
|
+
// This index also has a reference to the resolve function for the
|
|
259
|
+
// associated promise for that request id
|
|
260
|
+
// If that is true ('truthy' via if (request)), then resolve the
|
|
261
|
+
// associated promise via request.resolve(data), where data is
|
|
262
|
+
// the value resolved by the promise
|
|
263
|
+
// Otherwise pass a variety of console warnings / logs - the message
|
|
264
|
+
// will not be handled and disappear from the future (i.e. every
|
|
265
|
+
// message needs a requestid set in waitingResponse to be caught
|
|
266
|
+
// We could probably add in a router for server initiated messages
|
|
267
|
+
// to be handled (under the second warning below)
|
|
268
|
+
async processMessage(t) {
|
|
269
|
+
try {
|
|
270
|
+
let n = JSON.parse(t.data);
|
|
271
|
+
if (Object.prototype.hasOwnProperty.call(n, "requestid")) {
|
|
272
|
+
const o = this.waitingResponse[n.requestid];
|
|
273
|
+
o ? o.resolve(n) : console.warn(
|
|
274
|
+
"Got data but found no associated request, already timed out?",
|
|
275
|
+
n
|
|
276
|
+
);
|
|
277
|
+
} else
|
|
278
|
+
console.warn("Got data without request id", n);
|
|
279
|
+
} catch {
|
|
280
|
+
console.log(t.data);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// Main entry point for calling functions with a simple
|
|
284
|
+
// callback to action to perform on the received data
|
|
285
|
+
// Exists here to reduce boilerplate for the calling function
|
|
286
|
+
async sendRequest(t, n, o = (r) => {
|
|
287
|
+
console.log(r);
|
|
288
|
+
}) {
|
|
289
|
+
this.sendPayload(t).then(
|
|
290
|
+
function(r) {
|
|
291
|
+
n(r);
|
|
292
|
+
},
|
|
293
|
+
function(r) {
|
|
294
|
+
o(r);
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
// Second entry point for one direction messages
|
|
299
|
+
// i.e. not expecting any responses. This bypasses
|
|
300
|
+
// the request-response promise functions above
|
|
301
|
+
// Attempts to JSON.stringify the object first,
|
|
302
|
+
// and just sends the object if cannot be made
|
|
303
|
+
// into a JSON string
|
|
304
|
+
sendMessage(t) {
|
|
305
|
+
const n = (() => {
|
|
306
|
+
try {
|
|
307
|
+
return JSON.stringify(t);
|
|
308
|
+
} catch {
|
|
309
|
+
return t;
|
|
310
|
+
}
|
|
311
|
+
})();
|
|
312
|
+
this.socket.readyState === y.OPEN ? this.socket.send(n) : this.recreateSocket(n);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function x() {
|
|
316
|
+
return document.compatMode == "BackCompat" ? document.body : document.documentElement;
|
|
317
|
+
}
|
|
318
|
+
function D() {
|
|
319
|
+
const e = x();
|
|
320
|
+
return {
|
|
321
|
+
width: e.clientWidth || window.innerWidth,
|
|
322
|
+
height: e.clientHeight || window.innerHeight
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function he() {
|
|
326
|
+
const e = x(), t = D();
|
|
327
|
+
return {
|
|
328
|
+
width: Math.max(e.scrollWidth, t.width),
|
|
329
|
+
height: Math.max(e.scrollHeight, t.height)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function we(e) {
|
|
333
|
+
const t = D(), n = e.getBoundingClientRect();
|
|
334
|
+
return n.bottom > 0 && n.top < t.height && n.right > 0 && n.left < t.width;
|
|
335
|
+
}
|
|
336
|
+
function U() {
|
|
337
|
+
const e = x();
|
|
338
|
+
return {
|
|
339
|
+
scrollLeft: e.scrollLeft,
|
|
340
|
+
scrollTop: e.scrollTop
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function X() {
|
|
344
|
+
const e = x();
|
|
345
|
+
return {
|
|
346
|
+
clientLeft: e.clientLeft,
|
|
347
|
+
clientTop: e.clientTop
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function G(e) {
|
|
351
|
+
let t = e.offsetLeft, n = e.offsetParent;
|
|
352
|
+
for (; n !== null; )
|
|
353
|
+
t += n.offsetLeft, n = n.offsetParent;
|
|
354
|
+
return t;
|
|
355
|
+
}
|
|
356
|
+
function V(e) {
|
|
357
|
+
let t = e.offsetTop, n = e.offsetParent;
|
|
358
|
+
for (; n !== null; )
|
|
359
|
+
t += n.offsetTop, n = n.offsetParent;
|
|
360
|
+
return t;
|
|
361
|
+
}
|
|
362
|
+
function ve(e) {
|
|
363
|
+
return {
|
|
364
|
+
x: G(e),
|
|
365
|
+
y: V(e)
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function be(e) {
|
|
369
|
+
const t = e.getBoundingClientRect(), n = U(), o = X();
|
|
370
|
+
return {
|
|
371
|
+
x: t.left + n.scrollLeft - o.clientLeft,
|
|
372
|
+
y: t.top + n.scrollTop - o.clientTop
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function Ee(e) {
|
|
376
|
+
const t = e.getBoundingClientRect();
|
|
377
|
+
return {
|
|
378
|
+
x: t.left,
|
|
379
|
+
y: t.top
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function Te() {
|
|
383
|
+
const e = x(), t = e.scrollHeight - e.clientHeight;
|
|
384
|
+
return t <= 0 ? 0 : e.scrollTop / t * 100;
|
|
385
|
+
}
|
|
386
|
+
function ke(e) {
|
|
387
|
+
if (e.pageX && e.pageY)
|
|
388
|
+
return { x: e.pageX, y: e.pageY };
|
|
389
|
+
const t = U(), n = X();
|
|
390
|
+
return {
|
|
391
|
+
x: e.clientX + t.scrollLeft - n.clientLeft,
|
|
392
|
+
y: e.clientY + t.scrollTop - n.clientTop
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function Le(e) {
|
|
396
|
+
return {
|
|
397
|
+
x: e.clientX,
|
|
398
|
+
y: e.clientY
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function xe(e) {
|
|
402
|
+
if (document.implementation.hasFeature("MouseEvents", "2.0"))
|
|
403
|
+
return e.button;
|
|
404
|
+
switch (e.button) {
|
|
405
|
+
case 0:
|
|
406
|
+
case 1:
|
|
407
|
+
case 3:
|
|
408
|
+
case 5:
|
|
409
|
+
case 7:
|
|
410
|
+
return 0;
|
|
411
|
+
case 2:
|
|
412
|
+
case 6:
|
|
413
|
+
return 2;
|
|
414
|
+
case 4:
|
|
415
|
+
return 1;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function ye() {
|
|
419
|
+
let e = navigator.userAgent;
|
|
420
|
+
return {
|
|
421
|
+
trident: e.indexOf("Trident") > -1,
|
|
422
|
+
//IE内核
|
|
423
|
+
presto: e.indexOf("Presto") > -1,
|
|
424
|
+
//opera内核
|
|
425
|
+
webKit: e.indexOf("AppleWebKit") > -1,
|
|
426
|
+
//苹果、谷歌内核
|
|
427
|
+
gecko: e.indexOf("Gecko") > -1 && e.indexOf("KHTML") == -1,
|
|
428
|
+
//火狐内核
|
|
429
|
+
mobile: !!e.match(/AppleWebKit.*Mobile.*/),
|
|
430
|
+
//是否为移动终端
|
|
431
|
+
ios: !!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
|
|
432
|
+
//ios终端
|
|
433
|
+
android: e.indexOf("Android") > -1 || e.indexOf("Linux") > -1,
|
|
434
|
+
//android终端或uc浏览器
|
|
435
|
+
iPhone: e.indexOf("iPhone") > -1,
|
|
436
|
+
//是否为iPhone或者QQHD浏览器
|
|
437
|
+
iPad: e.indexOf("iPad") > -1,
|
|
438
|
+
//是否iPad
|
|
439
|
+
webApp: e.indexOf("Safari") == -1
|
|
440
|
+
//是否web应该程序,没有头部与底部
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function Pe() {
|
|
444
|
+
return (navigator.browserLanguage || navigator.language).toLowerCase();
|
|
445
|
+
}
|
|
446
|
+
function W() {
|
|
447
|
+
return (
|
|
448
|
+
// Check if it is an iPhone
|
|
449
|
+
/iPhone/gi.test(window.navigator.platform) || // Check if it is an iPad. iPad reports itself as "MacIntel", but we can check if it is a touch
|
|
450
|
+
// screen. Let's hope that Apple doesn't release a touch screen Mac (or maybe this would then
|
|
451
|
+
// work as expected 🤔).
|
|
452
|
+
/Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
function J() {
|
|
456
|
+
return /Android/gi.test(window.navigator.userAgent);
|
|
457
|
+
}
|
|
458
|
+
function Ce() {
|
|
459
|
+
return W() || J();
|
|
460
|
+
}
|
|
461
|
+
function _e(e) {
|
|
462
|
+
var t = document.documentElement, n = window.devicePixelRatio;
|
|
463
|
+
t.dataset.dpr = n;
|
|
464
|
+
var o = 100, r = function() {
|
|
465
|
+
var l = Math.min(t.clientWidth, e);
|
|
466
|
+
t.dataset.width = l, t.dataset.rem = o = Math.round(100 * (l / e)), t.style.fontSize = o + "px";
|
|
467
|
+
};
|
|
468
|
+
r(), window.rem2px = function(l) {
|
|
469
|
+
return l = parseFloat(l), l * o;
|
|
470
|
+
}, window.px2rem = function(l) {
|
|
471
|
+
return l = parseFloat(l), l / o;
|
|
472
|
+
}, window.addEventListener && window.addEventListener(
|
|
473
|
+
"orientationchange" in window ? "orientationchange" : "resize",
|
|
474
|
+
r,
|
|
475
|
+
!1
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
require("path");
|
|
479
|
+
require("querystring");
|
|
480
|
+
require("util");
|
|
481
|
+
require("url");
|
|
482
|
+
function Ae(e) {
|
|
483
|
+
return btoa(encodeURIComponent(e)).replaceAll("+", "*").replaceAll("/", "-").replaceAll("=", "");
|
|
484
|
+
}
|
|
485
|
+
function Me(e) {
|
|
486
|
+
let t = e.replaceAll("*", "+").replaceAll("-", "/"), n = t.length % 4;
|
|
487
|
+
return n && (t = t.padEnd(t.length + (4 - n), "=")), decodeURIComponent(atob(t));
|
|
488
|
+
}
|
|
489
|
+
const Se = (e) => !/^([a-z]+:)?[\\/]/i.test(e);
|
|
490
|
+
function Re(e) {
|
|
491
|
+
let t;
|
|
492
|
+
try {
|
|
493
|
+
t = new URL(e);
|
|
494
|
+
} catch (n) {
|
|
495
|
+
return console.log(n), !1;
|
|
496
|
+
}
|
|
497
|
+
return t.protocol === "http:" || t.protocol === "https:";
|
|
498
|
+
}
|
|
499
|
+
function Ie() {
|
|
500
|
+
let e = location.search;
|
|
501
|
+
if (e) {
|
|
502
|
+
let t = {};
|
|
503
|
+
return e = e.substring(1, e.length), e.split("&").forEach((o) => {
|
|
504
|
+
t[o.split("=")[0]] = decodeURIComponent(o.split("=")[1]);
|
|
505
|
+
}), t;
|
|
506
|
+
} else
|
|
507
|
+
return !1;
|
|
508
|
+
}
|
|
509
|
+
const De = (e) => Array.from(new URLSearchParams(e)).reduce(
|
|
510
|
+
(t, [n, o]) => Object.assign({}, t, {
|
|
511
|
+
[n]: t[n] ? (Array.isArray(t[n]) ? t[n] : [t[n]]).concat(o) : o
|
|
512
|
+
}),
|
|
513
|
+
{}
|
|
514
|
+
);
|
|
515
|
+
function Oe(e) {
|
|
516
|
+
e = e || localStorage.theme, e || (e = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", localStorage.theme = e), document.documentElement.classList.toggle("dark", e === "dark");
|
|
517
|
+
}
|
|
518
|
+
class E {
|
|
519
|
+
static getEvent(t) {
|
|
520
|
+
const n = t.keyCode || t.charCode;
|
|
521
|
+
return {
|
|
522
|
+
code: n,
|
|
523
|
+
key: E.codeToKey(n)
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* keyToCode(keyName: string)
|
|
528
|
+
*
|
|
529
|
+
* @param keyName {string} - The keyName of the key you wish to get the code for.
|
|
530
|
+
*
|
|
531
|
+
* @return {number} - Will be the keycode of the given keyName, or -1 if it does not exist in
|
|
532
|
+
* the set of known keys.
|
|
533
|
+
*/
|
|
534
|
+
static keyToCode(t) {
|
|
535
|
+
return Object.prototype.hasOwnProperty.call(
|
|
536
|
+
E.keyToCodes,
|
|
537
|
+
t
|
|
538
|
+
) ? E.keyToCodes[t] : -1;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* codeToKey(code: string)
|
|
542
|
+
*
|
|
543
|
+
* @param code {string} - The key code to lookup the keyname for
|
|
544
|
+
*
|
|
545
|
+
* @reaturn {string} - Will be the keyname of the given Code or '' if it does not
|
|
546
|
+
* exist on the set of known codes.
|
|
547
|
+
*/
|
|
548
|
+
static codeToKey(t) {
|
|
549
|
+
return Object.prototype.hasOwnProperty.call(
|
|
550
|
+
E.codeToKeys,
|
|
551
|
+
t.toString()
|
|
552
|
+
) ? E.codeToKeys[t.toString()] : "";
|
|
553
|
+
}
|
|
554
|
+
static keyToCodes = {
|
|
555
|
+
0: 48,
|
|
556
|
+
1: 49,
|
|
557
|
+
2: 50,
|
|
558
|
+
3: 51,
|
|
559
|
+
4: 52,
|
|
560
|
+
5: 53,
|
|
561
|
+
6: 54,
|
|
562
|
+
7: 55,
|
|
563
|
+
8: 56,
|
|
564
|
+
9: 57,
|
|
565
|
+
spacebar: 32,
|
|
566
|
+
backspace: 8,
|
|
567
|
+
tab: 9,
|
|
568
|
+
enter: 13,
|
|
569
|
+
shift: 16,
|
|
570
|
+
ctrl: 17,
|
|
571
|
+
alt: 18,
|
|
572
|
+
pause_break: 19,
|
|
573
|
+
caps_lock: 20,
|
|
574
|
+
escape: 27,
|
|
575
|
+
page_up: 33,
|
|
576
|
+
page_down: 34,
|
|
577
|
+
end: 35,
|
|
578
|
+
home: 36,
|
|
579
|
+
left_arrow: 37,
|
|
580
|
+
up_arrow: 38,
|
|
581
|
+
right_arrow: 39,
|
|
582
|
+
down_arrow: 40,
|
|
583
|
+
insert: 45,
|
|
584
|
+
delete: 46,
|
|
585
|
+
a: 65,
|
|
586
|
+
b: 66,
|
|
587
|
+
c: 67,
|
|
588
|
+
d: 68,
|
|
589
|
+
e: 69,
|
|
590
|
+
f: 70,
|
|
591
|
+
g: 71,
|
|
592
|
+
h: 72,
|
|
593
|
+
i: 73,
|
|
594
|
+
j: 74,
|
|
595
|
+
k: 75,
|
|
596
|
+
l: 76,
|
|
597
|
+
m: 77,
|
|
598
|
+
n: 78,
|
|
599
|
+
o: 79,
|
|
600
|
+
p: 80,
|
|
601
|
+
q: 81,
|
|
602
|
+
r: 82,
|
|
603
|
+
s: 83,
|
|
604
|
+
t: 84,
|
|
605
|
+
u: 85,
|
|
606
|
+
v: 86,
|
|
607
|
+
w: 87,
|
|
608
|
+
x: 88,
|
|
609
|
+
y: 89,
|
|
610
|
+
z: 90,
|
|
611
|
+
left_window_key: 91,
|
|
612
|
+
right_window_key: 92,
|
|
613
|
+
select_key: 93,
|
|
614
|
+
numpad_0: 96,
|
|
615
|
+
numpad_1: 97,
|
|
616
|
+
numpad_2: 98,
|
|
617
|
+
numpad_3: 99,
|
|
618
|
+
numpad_4: 100,
|
|
619
|
+
numpad_5: 101,
|
|
620
|
+
numpad_6: 102,
|
|
621
|
+
numpad_7: 103,
|
|
622
|
+
numpad_8: 104,
|
|
623
|
+
numpad_9: 105,
|
|
624
|
+
multiply: 106,
|
|
625
|
+
add: 107,
|
|
626
|
+
subtract: 109,
|
|
627
|
+
decimal_point: 110,
|
|
628
|
+
divide: 111,
|
|
629
|
+
f1: 112,
|
|
630
|
+
f2: 113,
|
|
631
|
+
f3: 114,
|
|
632
|
+
f4: 115,
|
|
633
|
+
f5: 116,
|
|
634
|
+
f6: 117,
|
|
635
|
+
f7: 118,
|
|
636
|
+
f8: 119,
|
|
637
|
+
f9: 120,
|
|
638
|
+
f10: 121,
|
|
639
|
+
f11: 122,
|
|
640
|
+
f12: 123,
|
|
641
|
+
num_lock: 144,
|
|
642
|
+
scroll_lock: 145,
|
|
643
|
+
semi_colon: 186,
|
|
644
|
+
equal_sign: 187,
|
|
645
|
+
comma: 188,
|
|
646
|
+
dash: 189,
|
|
647
|
+
period: 190,
|
|
648
|
+
forward_slash: 191,
|
|
649
|
+
grave_accent: 192,
|
|
650
|
+
open_bracket: 219,
|
|
651
|
+
back_slash: 220,
|
|
652
|
+
close_braket: 221,
|
|
653
|
+
single_quote: 222
|
|
654
|
+
};
|
|
655
|
+
static codeToKeys = {
|
|
656
|
+
8: "backspace",
|
|
657
|
+
9: "tab",
|
|
658
|
+
13: "enter",
|
|
659
|
+
16: "shift",
|
|
660
|
+
17: "ctrl",
|
|
661
|
+
18: "alt",
|
|
662
|
+
19: "pause_break",
|
|
663
|
+
20: "caps_lock",
|
|
664
|
+
27: "escape",
|
|
665
|
+
32: "spacebar",
|
|
666
|
+
33: "page_up",
|
|
667
|
+
34: "page_down",
|
|
668
|
+
35: "end",
|
|
669
|
+
36: "home",
|
|
670
|
+
37: "left_arrow",
|
|
671
|
+
38: "up_arrow",
|
|
672
|
+
39: "right_arrow",
|
|
673
|
+
40: "down_arrow",
|
|
674
|
+
45: "insert",
|
|
675
|
+
46: "delete",
|
|
676
|
+
48: "0",
|
|
677
|
+
49: "1",
|
|
678
|
+
50: "2",
|
|
679
|
+
51: "3",
|
|
680
|
+
52: "4",
|
|
681
|
+
53: "5",
|
|
682
|
+
54: "6",
|
|
683
|
+
55: "7",
|
|
684
|
+
56: "8",
|
|
685
|
+
57: "9",
|
|
686
|
+
65: "a",
|
|
687
|
+
66: "b",
|
|
688
|
+
67: "c",
|
|
689
|
+
68: "d",
|
|
690
|
+
69: "e",
|
|
691
|
+
70: "f",
|
|
692
|
+
71: "g",
|
|
693
|
+
72: "h",
|
|
694
|
+
73: "i",
|
|
695
|
+
74: "j",
|
|
696
|
+
75: "k",
|
|
697
|
+
76: "l",
|
|
698
|
+
77: "m",
|
|
699
|
+
78: "n",
|
|
700
|
+
79: "o",
|
|
701
|
+
80: "p",
|
|
702
|
+
81: "q",
|
|
703
|
+
82: "r",
|
|
704
|
+
83: "s",
|
|
705
|
+
84: "t",
|
|
706
|
+
85: "u",
|
|
707
|
+
86: "v",
|
|
708
|
+
87: "w",
|
|
709
|
+
88: "x",
|
|
710
|
+
89: "y",
|
|
711
|
+
90: "z",
|
|
712
|
+
91: "left_window_key",
|
|
713
|
+
92: "right_window_key",
|
|
714
|
+
93: "select_key",
|
|
715
|
+
96: "numpad_0",
|
|
716
|
+
97: "numpad_1",
|
|
717
|
+
98: "numpad_2",
|
|
718
|
+
99: "numpad_3",
|
|
719
|
+
100: "numpad_4",
|
|
720
|
+
101: "numpad_5",
|
|
721
|
+
102: "numpad_6",
|
|
722
|
+
103: "numpad_7",
|
|
723
|
+
104: "numpad_8",
|
|
724
|
+
105: "numpad_9",
|
|
725
|
+
106: "multiply",
|
|
726
|
+
107: "add",
|
|
727
|
+
109: "subtract",
|
|
728
|
+
110: "decimal_point",
|
|
729
|
+
111: "divide",
|
|
730
|
+
112: "f1",
|
|
731
|
+
113: "f2",
|
|
732
|
+
114: "f3",
|
|
733
|
+
115: "f4",
|
|
734
|
+
116: "f5",
|
|
735
|
+
117: "f6",
|
|
736
|
+
118: "f7",
|
|
737
|
+
119: "f8",
|
|
738
|
+
120: "f9",
|
|
739
|
+
121: "f10",
|
|
740
|
+
122: "f11",
|
|
741
|
+
123: "f12",
|
|
742
|
+
144: "num_lock",
|
|
743
|
+
145: "scroll_lock",
|
|
744
|
+
186: "semi_colon",
|
|
745
|
+
187: "equal_sign",
|
|
746
|
+
188: "comma",
|
|
747
|
+
189: "dash",
|
|
748
|
+
190: "period",
|
|
749
|
+
191: "forward_slash",
|
|
750
|
+
192: "grave_accent",
|
|
751
|
+
219: "open_bracket",
|
|
752
|
+
220: "back_slash",
|
|
753
|
+
221: "close_braket",
|
|
754
|
+
222: "single_quote"
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
const qe = (e) => navigator.clipboard.writeText(e), Be = () => window.getSelection().toString(), Ue = (e) => e === document.activeElement, Xe = (e) => [].slice.call(e.parentNode.children).filter((t) => t !== e), He = () => window.scrollTo(0, 0), Fe = () => !document.hidden, je = () => history.back(), $e = () => history.go(-1);
|
|
758
|
+
function ze(e) {
|
|
759
|
+
let t = document.createElement("script");
|
|
760
|
+
t.type = "text/javascript", t.src = e, t.async = !1, document.body.appendChild(t), t.onload = () => {
|
|
761
|
+
}, t.onerror = () => {
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function Ge(e) {
|
|
765
|
+
let t = e[0];
|
|
766
|
+
for (let n = 1; n < arguments.length; n++) {
|
|
767
|
+
let o = String(arguments[n]);
|
|
768
|
+
t += o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), t += e[n];
|
|
769
|
+
}
|
|
770
|
+
return t;
|
|
771
|
+
}
|
|
772
|
+
function Ve(e) {
|
|
773
|
+
const t = /<%=(.+?)%>/g, n = /<%([\s\S]+?)%>/g;
|
|
774
|
+
return e = e.replace(t, "`); \n echo( $1 ); \n echo(`").replace(n, "`); \n $1 \n echo(`"), e = "echo(`" + e + "`);", `(function parse(data){
|
|
775
|
+
let output = "";
|
|
776
|
+
|
|
777
|
+
function echo(html){
|
|
778
|
+
output += html;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
${e}
|
|
782
|
+
|
|
783
|
+
return output;
|
|
784
|
+
})`;
|
|
785
|
+
}
|
|
786
|
+
function We(e, t, n) {
|
|
787
|
+
e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent ? e.attachEvent("on" + t, n) : e["on" + t] = n;
|
|
788
|
+
}
|
|
789
|
+
function Je(e, t, n) {
|
|
790
|
+
e.removeEventListener ? e.removeEventListener(t, n, !1) : e.detachEvent ? e.detachEvent("on" + t, n) : e["on" + t] = null;
|
|
791
|
+
}
|
|
792
|
+
function Ye(e) {
|
|
793
|
+
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0;
|
|
794
|
+
}
|
|
795
|
+
function Qe(e) {
|
|
796
|
+
e.preventDefault ? e.preventDefault : e.returnValue = !1;
|
|
797
|
+
}
|
|
798
|
+
function Ke(e) {
|
|
799
|
+
return e || window.event;
|
|
800
|
+
}
|
|
801
|
+
function Ze(e) {
|
|
802
|
+
return e.target || e.srcElement;
|
|
803
|
+
}
|
|
804
|
+
function Ne(e) {
|
|
805
|
+
return e.relatedTarget ? e.relatedTarget : e.toElement ? e.toElement : e.fromElement ? e.fromElement : null;
|
|
806
|
+
}
|
|
807
|
+
function et() {
|
|
808
|
+
return !!(window.File && window.FileReader && window.FileList && window.Blob);
|
|
809
|
+
}
|
|
810
|
+
window.requestAnimationFrame || (window.requestAnimationFrame = function() {
|
|
811
|
+
return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) {
|
|
812
|
+
window.setTimeout(e, 1e3 / 60);
|
|
813
|
+
};
|
|
814
|
+
}());
|
|
815
|
+
const tt = (e, t) => {
|
|
816
|
+
var n = document.getElementById(e), o = n.getContext("2d");
|
|
817
|
+
(function r() {
|
|
818
|
+
window.requestAnimationFrame(r), o.clearRect(0, 0, n.width, n.height), t(o);
|
|
819
|
+
})();
|
|
820
|
+
};
|
|
821
|
+
function nt(e) {
|
|
822
|
+
return new Promise(function(t, n) {
|
|
823
|
+
const o = new Image();
|
|
824
|
+
o.onload = function() {
|
|
825
|
+
t(o);
|
|
826
|
+
}, o.onerror = function() {
|
|
827
|
+
n(new Error("Could not load image at " + e));
|
|
828
|
+
}, o.src = e;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
function ot() {
|
|
832
|
+
const e = document.getElementsByTagName("img"), t = D().height;
|
|
833
|
+
let n = 0;
|
|
834
|
+
for (let o = n; o < e.length; o++)
|
|
835
|
+
e[o].getBoundingClientRect().top < t && (e[o].src = e[o].getAttribute("data-src"), n = o + 1);
|
|
836
|
+
}
|
|
837
|
+
function rt(e) {
|
|
838
|
+
var t = [], n = [], o = [], r, l, f, d, u = 0, T = document.createElement("canvas"), k = T.getContext("2d"), h = document.createElement("image");
|
|
839
|
+
h.src = e, T.width = h.width, T.height = h.height, k.drawImage(h, 0, 0);
|
|
840
|
+
for (var w = k.getImageData(0, 0, h.width, h.height).data, g = 0; g < w.length; g += 4)
|
|
841
|
+
t[u] = w[g], n[u] = w[g + 1], o[u] = w[g + 2], u += 1;
|
|
842
|
+
return r = R(t), l = R(n), f = R(o), d = "rgb(" + r + "," + l + "," + f + ")", d;
|
|
843
|
+
}
|
|
844
|
+
function R(e) {
|
|
845
|
+
var t = {}, n = [], o = [], r = 0;
|
|
846
|
+
for (let u = 0; u < e.length; u++)
|
|
847
|
+
t[e[u]] ? n.push(e[u]) : t[e[u]] = 1;
|
|
848
|
+
for (let u = 0; u < n.length; u++) {
|
|
849
|
+
r = 0;
|
|
850
|
+
for (var l = 0; l < n.length; l++)
|
|
851
|
+
n[u] === n[l] && (r += 1), o[u] = r;
|
|
852
|
+
}
|
|
853
|
+
for (var f = Math.max.apply(null, o), d = 0; d < o.length; d++)
|
|
854
|
+
if (o[d] === f)
|
|
855
|
+
return;
|
|
856
|
+
return n[d];
|
|
857
|
+
}
|
|
858
|
+
const it = function(e) {
|
|
859
|
+
e || (e = "2d");
|
|
860
|
+
const t = function() {
|
|
861
|
+
const i = document.createElement("canvas"), a = i.getContext(
|
|
862
|
+
e
|
|
863
|
+
), s = !!a;
|
|
864
|
+
return {
|
|
865
|
+
canvas: s,
|
|
866
|
+
imageData: s && !!a.getImageData,
|
|
867
|
+
dataURL: !!i.toDataURL,
|
|
868
|
+
btoa: !!window.btoa
|
|
869
|
+
};
|
|
870
|
+
}(), n = "image/octet-stream";
|
|
871
|
+
function o(i, a, s) {
|
|
872
|
+
const c = i.width, m = i.height;
|
|
873
|
+
a === void 0 && (a = c), s === void 0 && (s = m);
|
|
874
|
+
const p = document.createElement("canvas"), v = p.getContext(
|
|
875
|
+
e
|
|
876
|
+
);
|
|
877
|
+
return p.width = a, p.height = s, v.drawImage(i, 0, 0, c, m, 0, 0, a, s), p;
|
|
878
|
+
}
|
|
879
|
+
function r(i, a, s, c) {
|
|
880
|
+
return e == "2d" && (i = o(i, s, c)), i.toDataURL(a);
|
|
881
|
+
}
|
|
882
|
+
function l(i, a, s = "name") {
|
|
883
|
+
const c = document.createElement("a");
|
|
884
|
+
c.download = s + "." + a, c.href = i, c.click();
|
|
885
|
+
}
|
|
886
|
+
function f(i) {
|
|
887
|
+
const a = document.createElement("img");
|
|
888
|
+
return a.src = i, a;
|
|
889
|
+
}
|
|
890
|
+
function d(i) {
|
|
891
|
+
return i = i.toLowerCase().replace(/jpg/i, "jpeg"), "image/" + i.match(/png|jpeg|bmp|gif/)?.[0];
|
|
892
|
+
}
|
|
893
|
+
function u(i) {
|
|
894
|
+
if (!window.btoa)
|
|
895
|
+
throw "btoa undefined";
|
|
896
|
+
let a = "";
|
|
897
|
+
if (typeof i == "string")
|
|
898
|
+
a = i;
|
|
899
|
+
else
|
|
900
|
+
for (let s = 0; s < i.length; s++)
|
|
901
|
+
a += String.fromCharCode(i[s]);
|
|
902
|
+
return btoa(a);
|
|
903
|
+
}
|
|
904
|
+
function T(i) {
|
|
905
|
+
const a = e == "2d" ? void 0 : { preserveDrawingBuffer: !0 };
|
|
906
|
+
return i.getContext(e, a);
|
|
907
|
+
}
|
|
908
|
+
function k(i) {
|
|
909
|
+
const a = i.width, s = i.height;
|
|
910
|
+
return T(i).getImageData(0, 0, a, s);
|
|
911
|
+
}
|
|
912
|
+
function h(i, a) {
|
|
913
|
+
return "data:" + a + ";base64," + i;
|
|
914
|
+
}
|
|
915
|
+
const w = function(i) {
|
|
916
|
+
const a = i.width, s = i.height, c = a * s * 3, m = c + 54, p = [
|
|
917
|
+
// WORD bfType -- The file type signature; must be "BM"
|
|
918
|
+
66,
|
|
919
|
+
77,
|
|
920
|
+
// DWORD bfSize -- The size, in bytes, of the bitmap file
|
|
921
|
+
m & 255,
|
|
922
|
+
m >> 8 & 255,
|
|
923
|
+
m >> 16 & 255,
|
|
924
|
+
m >> 24 & 255,
|
|
925
|
+
// WORD bfReserved1 -- Reserved; must be zero
|
|
926
|
+
0,
|
|
927
|
+
0,
|
|
928
|
+
// WORD bfReserved2 -- Reserved; must be zero
|
|
929
|
+
0,
|
|
930
|
+
0,
|
|
931
|
+
// DWORD bfOffBits -- The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.
|
|
932
|
+
54,
|
|
933
|
+
0,
|
|
934
|
+
0,
|
|
935
|
+
0
|
|
936
|
+
], v = [
|
|
937
|
+
// DWORD biSize -- The number of bytes required by the structure
|
|
938
|
+
40,
|
|
939
|
+
0,
|
|
940
|
+
0,
|
|
941
|
+
0,
|
|
942
|
+
// LONG biWidth -- The width of the bitmap, in pixels
|
|
943
|
+
a & 255,
|
|
944
|
+
a >> 8 & 255,
|
|
945
|
+
a >> 16 & 255,
|
|
946
|
+
a >> 24 & 255,
|
|
947
|
+
// LONG biHeight -- The height of the bitmap, in pixels
|
|
948
|
+
s & 255,
|
|
949
|
+
s >> 8 & 255,
|
|
950
|
+
s >> 16 & 255,
|
|
951
|
+
s >> 24 & 255,
|
|
952
|
+
// WORD biPlanes -- The number of planes for the target device. This value must be set to 1
|
|
953
|
+
1,
|
|
954
|
+
0,
|
|
955
|
+
// WORD biBitCount -- The number of bits-per-pixel, 24 bits-per-pixel -- the bitmap
|
|
956
|
+
// has a maximum of 2^24 colors (16777216, Truecolor)
|
|
957
|
+
24,
|
|
958
|
+
0,
|
|
959
|
+
// DWORD biCompression -- The type of compression, BI_RGB (code 0) -- uncompressed
|
|
960
|
+
0,
|
|
961
|
+
0,
|
|
962
|
+
0,
|
|
963
|
+
0,
|
|
964
|
+
// DWORD biSizeImage -- The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps
|
|
965
|
+
c & 255,
|
|
966
|
+
c >> 8 & 255,
|
|
967
|
+
c >> 16 & 255,
|
|
968
|
+
c >> 24 & 255,
|
|
969
|
+
// LONG biXPelsPerMeter, unused
|
|
970
|
+
0,
|
|
971
|
+
0,
|
|
972
|
+
0,
|
|
973
|
+
0,
|
|
974
|
+
// LONG biYPelsPerMeter, unused
|
|
975
|
+
0,
|
|
976
|
+
0,
|
|
977
|
+
0,
|
|
978
|
+
0,
|
|
979
|
+
// DWORD biClrUsed, the number of color indexes of palette, unused
|
|
980
|
+
0,
|
|
981
|
+
0,
|
|
982
|
+
0,
|
|
983
|
+
0,
|
|
984
|
+
// DWORD biClrImportant, unused
|
|
985
|
+
0,
|
|
986
|
+
0,
|
|
987
|
+
0,
|
|
988
|
+
0
|
|
989
|
+
], P = (4 - a * 3 % 4) % 4, C = i.data;
|
|
990
|
+
let O = "";
|
|
991
|
+
const H = a << 2;
|
|
992
|
+
let q = s;
|
|
993
|
+
const _ = String.fromCharCode;
|
|
994
|
+
do {
|
|
995
|
+
const A = H * (q - 1);
|
|
996
|
+
let M = "";
|
|
997
|
+
for (let b = 0; b < a; b++) {
|
|
998
|
+
const S = b << 2;
|
|
999
|
+
M += _(C[A + S + 2]) + _(C[A + S + 1]) + _(C[A + S]);
|
|
1000
|
+
}
|
|
1001
|
+
for (let b = 0; b < P; b++)
|
|
1002
|
+
M += String.fromCharCode(0);
|
|
1003
|
+
O += M;
|
|
1004
|
+
} while (--q);
|
|
1005
|
+
return u(p.concat(v)) + u(O);
|
|
1006
|
+
}, g = function(i, a, s, c, m) {
|
|
1007
|
+
const p = c;
|
|
1008
|
+
if (t.canvas && t.dataURL)
|
|
1009
|
+
if (typeof i == "string" && (i = document.getElementById(i)), c === void 0 && (c = "png"), c = d(c), /bmp/.test(c)) {
|
|
1010
|
+
const v = k(o(i, a, s)), P = w(v);
|
|
1011
|
+
l(h(P, n), p, m);
|
|
1012
|
+
} else {
|
|
1013
|
+
const v = r(i, c, a, s);
|
|
1014
|
+
l(v.replace(c, n), p, m);
|
|
1015
|
+
}
|
|
1016
|
+
}, L = function(i, a, s, c) {
|
|
1017
|
+
if (t.canvas && t.dataURL)
|
|
1018
|
+
if (typeof i == "string" && (i = document.getElementById(i)), c === void 0 && (c = "png"), c = d(c), /bmp/.test(c)) {
|
|
1019
|
+
const m = k(o(i, a, s)), p = w(m);
|
|
1020
|
+
return f(h(p, "image/bmp"));
|
|
1021
|
+
} else {
|
|
1022
|
+
const m = r(i, c, a, s);
|
|
1023
|
+
return f(m);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
return {
|
|
1027
|
+
saveAsImage: g,
|
|
1028
|
+
saveAsPNG: function(i, a, s, c) {
|
|
1029
|
+
return g(i, a, s, "png", c);
|
|
1030
|
+
},
|
|
1031
|
+
saveAsJPEG: function(i, a, s, c) {
|
|
1032
|
+
return g(i, a, s, "jpeg", c);
|
|
1033
|
+
},
|
|
1034
|
+
saveAsGIF: function(i, a, s, c) {
|
|
1035
|
+
return g(i, a, s, "gif", c);
|
|
1036
|
+
},
|
|
1037
|
+
saveAsBMP: function(i, a, s, c) {
|
|
1038
|
+
return g(i, a, s, "bmp", c);
|
|
1039
|
+
},
|
|
1040
|
+
convertToImage: L,
|
|
1041
|
+
convertToPNG: function(i, a, s) {
|
|
1042
|
+
return L(i, a, s, "png");
|
|
1043
|
+
},
|
|
1044
|
+
convertToJPEG: function(i, a, s) {
|
|
1045
|
+
return L(i, a, s, "jpeg");
|
|
1046
|
+
},
|
|
1047
|
+
convertToGIF: function(i, a, s) {
|
|
1048
|
+
return L(i, a, s, "gif");
|
|
1049
|
+
},
|
|
1050
|
+
convertToBMP: function(i, a, s) {
|
|
1051
|
+
return L(i, a, s, "bmp");
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
function at() {
|
|
1056
|
+
var e = null;
|
|
1057
|
+
if (window.ActiveXObject)
|
|
1058
|
+
for (var t = [
|
|
1059
|
+
"Microsoft.XMLHTTP",
|
|
1060
|
+
"MSXML6.XMLHTTP",
|
|
1061
|
+
"MSXML5.XMLHTTP",
|
|
1062
|
+
"MSXML4.XMLHTTP",
|
|
1063
|
+
"MSXML3.XMLHTTP",
|
|
1064
|
+
"MSXML2.XMLHTTP",
|
|
1065
|
+
"MSXML.XMLHTTP"
|
|
1066
|
+
], n = 0; n < t.length; n++)
|
|
1067
|
+
try {
|
|
1068
|
+
e = new window.ActiveXObject(t[n]);
|
|
1069
|
+
break;
|
|
1070
|
+
} catch {
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
else
|
|
1074
|
+
e = new XMLHttpRequest();
|
|
1075
|
+
return e;
|
|
1076
|
+
}
|
|
1077
|
+
function st(e) {
|
|
1078
|
+
if (e.action) {
|
|
1079
|
+
if (e.method.toLowerCase() === "post")
|
|
1080
|
+
return {
|
|
1081
|
+
url: e.action,
|
|
1082
|
+
data: new FormData(e)
|
|
1083
|
+
};
|
|
1084
|
+
for (var t = "", n = 0; n < e.elements.length; n++) {
|
|
1085
|
+
var o = e.elements[n];
|
|
1086
|
+
if (o.hasAttribute("name")) {
|
|
1087
|
+
var r = o.nodeName.toUpperCase() === "INPUT" ? o.getAttribute("type").toUpperCase() : "TEXT";
|
|
1088
|
+
if (r === "FILE")
|
|
1089
|
+
for (var l = 0; l < o.files.length; t += "&" + escape(o.name) + "=" + escape(o.files[l++].name))
|
|
1090
|
+
;
|
|
1091
|
+
else
|
|
1092
|
+
(r !== "RADIO" && r !== "CHECKBOX" || o.checked) && (t += "&" + escape(o.name) + "=" + escape(o.value));
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return {
|
|
1096
|
+
url: e.action.replace(
|
|
1097
|
+
/(?:\?.*)?$/,
|
|
1098
|
+
t.replace(/^&/, "?")
|
|
1099
|
+
),
|
|
1100
|
+
data: null
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function ct(e, t) {
|
|
1105
|
+
return new Promise((n, o) => {
|
|
1106
|
+
var r = new XMLHttpRequest(), l = function() {
|
|
1107
|
+
o("The request for " + e + " is timed out for " + t + ".");
|
|
1108
|
+
}, f = function(d) {
|
|
1109
|
+
r.readyState === 4 && (r.status === 200 ? n(r.response) : o(r.statusText));
|
|
1110
|
+
};
|
|
1111
|
+
r.open("GET", e), r.onload = f, r.timeout = t, r.ontimeout = l, r.upload.addEventListener(
|
|
1112
|
+
"progress",
|
|
1113
|
+
function(d) {
|
|
1114
|
+
if (d.lengthComputable) {
|
|
1115
|
+
const u = Math.round(d.loaded * 100 / d.total);
|
|
1116
|
+
console.log(u + "%");
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
!1
|
|
1120
|
+
), r.upload.addEventListener("load", function(d) {
|
|
1121
|
+
}, !1), r.send(null);
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
function lt(e, t, n) {
|
|
1125
|
+
return fetch(
|
|
1126
|
+
e,
|
|
1127
|
+
Object.assign(
|
|
1128
|
+
{
|
|
1129
|
+
method: "POST",
|
|
1130
|
+
// GET, POST, PUT, DELETE
|
|
1131
|
+
headers: {
|
|
1132
|
+
// "Content-Type": "application/json"
|
|
1133
|
+
// "Content-Type": "application/x-www-form-urlencoded"
|
|
1134
|
+
},
|
|
1135
|
+
// 请求的头信息,形式为 Headers 对象或 ByteString
|
|
1136
|
+
body: {},
|
|
1137
|
+
// JSON.stringify(data) 请求发送的数据 blob、BufferSource、FormData、URLSearchParams(get 或head 方法中不能包含 body)
|
|
1138
|
+
mode: "",
|
|
1139
|
+
//请求的模式,是否跨域等,如 cors、 no-cors 或 same-origin
|
|
1140
|
+
credentials: "",
|
|
1141
|
+
//cookie 的跨域策略,如 omit、same-origin 或 include
|
|
1142
|
+
cache: "",
|
|
1143
|
+
//请求的 cache 模式: default、no-store、reload、no-cache、 force-cache 或 only-if-cached
|
|
1144
|
+
redirect: "follow",
|
|
1145
|
+
// manual, *follow, error
|
|
1146
|
+
referrerPolicy: "no-referrer"
|
|
1147
|
+
// no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
|
|
1148
|
+
},
|
|
1149
|
+
t
|
|
1150
|
+
)
|
|
1151
|
+
).then((o) => o.json());
|
|
1152
|
+
}
|
|
1153
|
+
function ut(e, t) {
|
|
1154
|
+
var n = new XMLHttpRequest();
|
|
1155
|
+
n.open("HEAD", e), n.filepath = e, n.callback = t, n.onload = function() {
|
|
1156
|
+
var o = parseFloat(
|
|
1157
|
+
window.localStorage.getItem("lm_" + this.filepath)
|
|
1158
|
+
), r = Date.parse(this.getResponseHeader("Last-Modified"));
|
|
1159
|
+
(isNaN(o) || r > o) && (window.localStorage.setItem("lm_" + this.filepath, Date.now()), isFinite(o) && this.callback(r, o));
|
|
1160
|
+
}, n.send();
|
|
1161
|
+
}
|
|
1162
|
+
export {
|
|
1163
|
+
I as BaseError,
|
|
1164
|
+
it as Canvas2Image,
|
|
1165
|
+
E as DOMKeyboardKeyCode,
|
|
1166
|
+
F as EnvironmentError,
|
|
1167
|
+
B as FileSelectCancelError,
|
|
1168
|
+
j as IllegalFileError,
|
|
1169
|
+
y as WebSocket,
|
|
1170
|
+
We as addEventListener,
|
|
1171
|
+
Re as checkHttpUrl,
|
|
1172
|
+
pe as clearCookies,
|
|
1173
|
+
qe as copyToClipboard,
|
|
1174
|
+
at as createXMLHttpRequest,
|
|
1175
|
+
tt as drawCanvasInWeb,
|
|
1176
|
+
lt as fetchUseFetch,
|
|
1177
|
+
ct as fetchUseXMLHttpRequest,
|
|
1178
|
+
le as file2Image,
|
|
1179
|
+
ce as fn2ObjectURL,
|
|
1180
|
+
Pe as getBrowserLanguage,
|
|
1181
|
+
ye as getBrowserUserAgent,
|
|
1182
|
+
me as getCookie,
|
|
1183
|
+
ge as getCookieObject,
|
|
1184
|
+
x as getDocumentElement,
|
|
1185
|
+
G as getElementLeftInPage,
|
|
1186
|
+
be as getElementPositionInPage,
|
|
1187
|
+
ve as getElementPositionInPage2,
|
|
1188
|
+
Ee as getElementPositionInViewport,
|
|
1189
|
+
V as getElementTopInPage,
|
|
1190
|
+
Ke as getEvent,
|
|
1191
|
+
$ as getFileExtension,
|
|
1192
|
+
se as getFileType,
|
|
1193
|
+
st as getFormElementData,
|
|
1194
|
+
rt as getImageColor,
|
|
1195
|
+
xe as getMouseButton,
|
|
1196
|
+
ke as getMousePositionInPage,
|
|
1197
|
+
Le as getMousePositionInViewport,
|
|
1198
|
+
X as getPageClient,
|
|
1199
|
+
U as getPageScroll,
|
|
1200
|
+
he as getPageSize,
|
|
1201
|
+
Te as getPageVerticalScrollPercent,
|
|
1202
|
+
Ne as getRelatedTarget,
|
|
1203
|
+
Ie as getSearchData,
|
|
1204
|
+
Be as getSelectedText,
|
|
1205
|
+
Ze as getTarget,
|
|
1206
|
+
De as getUrlParams,
|
|
1207
|
+
D as getViewportSize,
|
|
1208
|
+
Q as handleDragAndDropFiles,
|
|
1209
|
+
Y as handleInputFiles,
|
|
1210
|
+
ut as ifWebFileHasChanged,
|
|
1211
|
+
J as isAndroid,
|
|
1212
|
+
te as isAudio,
|
|
1213
|
+
et as isBrowserSupportFileAPI,
|
|
1214
|
+
we as isElementInViewport,
|
|
1215
|
+
oe as isExcelDocument,
|
|
1216
|
+
Ue as isFocus,
|
|
1217
|
+
W as isIOS,
|
|
1218
|
+
N as isImage,
|
|
1219
|
+
ie as isJsonDocument,
|
|
1220
|
+
Ce as isMobile,
|
|
1221
|
+
re as isPowerPointDocument,
|
|
1222
|
+
Fe as isTabInView,
|
|
1223
|
+
Se as isURLRelative,
|
|
1224
|
+
ee as isVideo,
|
|
1225
|
+
ne as isWordDocument,
|
|
1226
|
+
ae as isXmlDocument,
|
|
1227
|
+
ot as lazyloadImages,
|
|
1228
|
+
nt as loadImageAsync,
|
|
1229
|
+
ze as loadScript,
|
|
1230
|
+
de as microTask,
|
|
1231
|
+
je as navigateBack,
|
|
1232
|
+
$e as navigateBack2,
|
|
1233
|
+
ue as onDocumentReady,
|
|
1234
|
+
z as patchDOM,
|
|
1235
|
+
Qe as preventDefault,
|
|
1236
|
+
Z as readeFile,
|
|
1237
|
+
Je as removeEventListener,
|
|
1238
|
+
Ge as saferHTML,
|
|
1239
|
+
He as scrollToTop,
|
|
1240
|
+
K as selectFile,
|
|
1241
|
+
fe as setCookie,
|
|
1242
|
+
_e as setRem,
|
|
1243
|
+
Oe as setTheme,
|
|
1244
|
+
Xe as siblings,
|
|
1245
|
+
Ye as stopPropagation,
|
|
1246
|
+
Ve as templateCompile,
|
|
1247
|
+
Me as urlsafe_b64decode,
|
|
1248
|
+
Ae as urlsafe_b64encode
|
|
1249
|
+
};
|
|
1250
|
+
//# sourceMappingURL=zyzgroup_core_web.js.map
|