@unicom-cloud/utils 0.1.4 → 0.1.10
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/constant/keyboardCode.js +41 -40
- package/constant/platform.js +14 -16
- package/content-disposition/index.js +56 -0
- package/cookie/src/index.js +46 -46
- package/dayjs/index.js +15 -0
- package/decimal/decimal.js +56 -56
- package/event-emitter/index.js +14 -23
- package/file/fileToURL.js +8 -9
- package/file/saveAs.js +1 -1
- package/index.js +42 -37
- package/mock/MockWebSocket.js +67 -90
- package/mock/MockXMLHttpRequest.js +51 -61
- package/package.json +1 -1
- package/random/address.js +10 -10
- package/screenfull/index.js +43 -43
- package/snapdom/src/api/preCache.js +39 -25
- package/snapdom/src/api/snapdom.js +56 -56
- package/snapdom/src/core/cache.js +3 -2
- package/snapdom/src/core/capture.js +62 -51
- package/snapdom/src/core/clone.js +38 -37
- package/snapdom/src/core/prepare.js +40 -34
- package/snapdom/src/modules/background.js +20 -22
- package/snapdom/src/modules/fonts.js +148 -45
- package/snapdom/src/modules/images.js +7 -7
- package/snapdom/src/modules/pseudo.js +77 -48
- package/snapdom/src/modules/styles.js +7 -8
- package/snapdom/src/utils/helpers.js +90 -38
- package/tree/index.js +31 -32
- package/turbo-stream/src/encode.js +149 -152
- package/turbo-stream/src/shared.js +155 -173
package/mock/MockWebSocket.js
CHANGED
|
@@ -1,117 +1,94 @@
|
|
|
1
|
-
var k = (i) => {
|
|
2
|
-
throw TypeError(i);
|
|
3
|
-
};
|
|
4
|
-
var _ = (i, n, t) => n.has(i) || k("Cannot " + t);
|
|
5
|
-
var e = (i, n, t) => (_(i, n, "read from private field"), t ? t.call(i) : n.get(i)), c = (i, n, t) => n.has(i) ? k("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(i) : n.set(i, t), r = (i, n, t, h) => (_(i, n, "write to private field"), h ? h.call(i, t) : n.set(i, t), t);
|
|
6
|
-
var O = (i, n, t, h) => ({
|
|
7
|
-
set _(s) {
|
|
8
|
-
r(i, n, s, t);
|
|
9
|
-
},
|
|
10
|
-
get _() {
|
|
11
|
-
return e(i, n, h);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
1
|
import "../is/index.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return h;
|
|
2
|
+
import r from "lodash/isRegExp";
|
|
3
|
+
import c from "lodash/isString";
|
|
4
|
+
const n = window.WebSocket, o = {};
|
|
5
|
+
function u(a = {}) {
|
|
6
|
+
for (const e in o) {
|
|
7
|
+
const s = o[e];
|
|
8
|
+
let t = s?.url, i = !1;
|
|
9
|
+
if (r(t) && (i = t?.test?.(a.url)), c(t) && (t === "*" ? i = !0 : i = t === a.url), i)
|
|
10
|
+
return s;
|
|
25
11
|
}
|
|
26
12
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
super();
|
|
32
|
-
c(this, g, -1);
|
|
33
|
-
c(this, w, -1);
|
|
34
|
-
c(this, v, E.CONNECTING);
|
|
35
|
-
c(this, l, null);
|
|
36
|
-
c(this, S, null);
|
|
37
|
-
c(this, p, 0);
|
|
38
|
-
c(this, d, []);
|
|
39
|
-
c(this, y, null);
|
|
40
|
-
if (r(this, l, x({ url: t })), e(this, l))
|
|
41
|
-
r(this, v, E.OPEN), r(this, g, setTimeout(
|
|
13
|
+
class l extends EventTarget {
|
|
14
|
+
constructor(e, s) {
|
|
15
|
+
if (super(), this.#t = u({ url: e }), this.#t)
|
|
16
|
+
this.#n = n.OPEN, this.#i = setTimeout(
|
|
42
17
|
() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.dispatchEvent(u), (a = this.onopen) == null || a.call(this, u), clearTimeout(e(this, g));
|
|
18
|
+
let t = new CustomEvent("open", {});
|
|
19
|
+
this.dispatchEvent(t), this.onopen?.(t), clearTimeout(this.#i);
|
|
46
20
|
},
|
|
47
|
-
|
|
48
|
-
)
|
|
21
|
+
this.#t?.openTimeout ?? Math.random() * 27
|
|
22
|
+
), this.#a = setInterval(
|
|
49
23
|
() => {
|
|
50
|
-
this.readyState ===
|
|
24
|
+
this.readyState === n.OPEN && this.#e.length && (this.send(this.#h), this.#s++);
|
|
51
25
|
},
|
|
52
|
-
|
|
53
|
-
)
|
|
26
|
+
this.#t?.messageTimeInterval ?? 3e3
|
|
27
|
+
);
|
|
54
28
|
else
|
|
55
|
-
return
|
|
29
|
+
return this.#o = new n(e, s);
|
|
56
30
|
}
|
|
31
|
+
#i = -1;
|
|
32
|
+
#a = -1;
|
|
33
|
+
#n = n.CONNECTING;
|
|
57
34
|
get readyState() {
|
|
58
|
-
return
|
|
35
|
+
return this.#t ? this.#n : super.readyState;
|
|
59
36
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this
|
|
37
|
+
#t = null;
|
|
38
|
+
#o = null;
|
|
39
|
+
#s = 0;
|
|
40
|
+
close(e, s) {
|
|
41
|
+
if (this.#t) {
|
|
42
|
+
if (this.readyState !== n.CLOSED) {
|
|
43
|
+
this.#n = n.CLOSED;
|
|
44
|
+
let t = new CloseEvent("close");
|
|
45
|
+
this.dispatchEvent(t), this.onclose?.(t);
|
|
67
46
|
}
|
|
68
|
-
clearTimeout(
|
|
47
|
+
clearTimeout(this.#i), clearInterval(this.#a), this.#s = 0, this.#e = [];
|
|
69
48
|
} else
|
|
70
|
-
|
|
49
|
+
this.#o?.close?.(e, s);
|
|
71
50
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
51
|
+
#e = [];
|
|
52
|
+
#h = null;
|
|
53
|
+
send(e) {
|
|
54
|
+
if (this.#t) {
|
|
55
|
+
this.#h = e;
|
|
56
|
+
let s = null;
|
|
77
57
|
try {
|
|
78
|
-
|
|
79
|
-
} catch (
|
|
80
|
-
console.error(
|
|
58
|
+
s = e && JSON.parse(e);
|
|
59
|
+
} catch (i) {
|
|
60
|
+
console.error(i);
|
|
81
61
|
}
|
|
82
|
-
|
|
83
|
-
(
|
|
84
|
-
) && e
|
|
85
|
-
const
|
|
86
|
-
if (e
|
|
87
|
-
e
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
data: (f == null ? void 0 : f({ ...m, sendCount: e(this, p) })) ?? f
|
|
62
|
+
s?.mockAutoUpdateKey && !this.#e.find(
|
|
63
|
+
(i) => i.mockAutoUpdateKey === s.mockAutoUpdateKey
|
|
64
|
+
) && this.#e.push(s);
|
|
65
|
+
const t = this.#t?.template;
|
|
66
|
+
if (this.#e.length)
|
|
67
|
+
this.#e.forEach((i, d, m) => {
|
|
68
|
+
let h = new MessageEvent("message", {
|
|
69
|
+
data: t?.({ ...i, sendCount: this.#s }) ?? t
|
|
91
70
|
});
|
|
92
|
-
this.dispatchEvent(
|
|
71
|
+
this.dispatchEvent(h), this.onmessage?.(h);
|
|
93
72
|
});
|
|
94
73
|
else {
|
|
95
|
-
let
|
|
96
|
-
data: (
|
|
74
|
+
let i = new MessageEvent("message", {
|
|
75
|
+
data: t?.({ ...s, sendCount: this.#s }) ?? t
|
|
97
76
|
});
|
|
98
|
-
this.dispatchEvent(
|
|
77
|
+
this.dispatchEvent(i), this.onmessage?.(i);
|
|
99
78
|
}
|
|
100
79
|
} else
|
|
101
|
-
|
|
80
|
+
this.#o?.send?.(e);
|
|
102
81
|
}
|
|
103
|
-
static add(
|
|
104
|
-
|
|
105
|
-
url:
|
|
106
|
-
template:
|
|
107
|
-
...
|
|
82
|
+
static add(e, s, t) {
|
|
83
|
+
e && (window.WebSocket = l, o[e.toString()] = {
|
|
84
|
+
url: e,
|
|
85
|
+
template: s,
|
|
86
|
+
...t
|
|
108
87
|
});
|
|
109
88
|
}
|
|
110
|
-
}
|
|
111
|
-
g = new WeakMap(), w = new WeakMap(), v = new WeakMap(), l = new WeakMap(), S = new WeakMap(), p = new WeakMap(), d = new WeakMap(), y = new WeakMap();
|
|
112
|
-
let D = I;
|
|
89
|
+
}
|
|
113
90
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
91
|
+
l as MockWebSocket,
|
|
92
|
+
n as WebSocketNative,
|
|
93
|
+
l as default
|
|
117
94
|
};
|
|
@@ -1,94 +1,84 @@
|
|
|
1
|
-
var q = (e) => {
|
|
2
|
-
throw TypeError(e);
|
|
3
|
-
};
|
|
4
|
-
var T = (e, n, t) => n.has(e) || q("Cannot " + t);
|
|
5
|
-
var i = (e, n, t) => (T(e, n, "read from private field"), t ? t.call(e) : n.get(e)), a = (e, n, t) => n.has(e) ? q("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), h = (e, n, t, s) => (T(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), y = (e, n, t) => (T(e, n, "access private method"), t);
|
|
6
1
|
import "../is/index.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return d;
|
|
2
|
+
import a from "lodash/isRegExp";
|
|
3
|
+
import p from "lodash/isString";
|
|
4
|
+
const r = window.XMLHttpRequest, o = {};
|
|
5
|
+
function c(u = {}) {
|
|
6
|
+
const t = u.method?.toLowerCase?.();
|
|
7
|
+
for (const e in o) {
|
|
8
|
+
const n = o[e];
|
|
9
|
+
let s = n?.url, i = n?.method?.toLowerCase?.() === t;
|
|
10
|
+
if (i && (a(s) && (i = s?.test?.(u.url)), p(s) && (s === "*" ? i = !0 : i = s === u.url)), i)
|
|
11
|
+
return n;
|
|
18
12
|
}
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
const N = class N extends E {
|
|
14
|
+
class h extends r {
|
|
22
15
|
constructor(t) {
|
|
23
16
|
super(t);
|
|
24
|
-
a(this, C);
|
|
25
|
-
a(this, o, null);
|
|
26
|
-
a(this, l, {
|
|
27
|
-
method: "",
|
|
28
|
-
url: "",
|
|
29
|
-
async: !0,
|
|
30
|
-
username: null,
|
|
31
|
-
password: null
|
|
32
|
-
});
|
|
33
|
-
a(this, g, E.UNSENT);
|
|
34
|
-
a(this, w, "");
|
|
35
|
-
a(this, p, E.UNSENT);
|
|
36
|
-
a(this, v, null);
|
|
37
17
|
}
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
#t = null;
|
|
19
|
+
#s = {
|
|
20
|
+
method: "",
|
|
21
|
+
url: "",
|
|
22
|
+
async: !0,
|
|
23
|
+
username: null,
|
|
24
|
+
password: null
|
|
25
|
+
};
|
|
26
|
+
open(t, e, n = !0, s = null, i = null) {
|
|
27
|
+
this.#s = { method: t, url: e, async: n, username: s, password: i }, this.#t = c(this.#s), super.open(t, e, n, s, i), this.#t && (this.#e = r.OPENED, this.dispatchEvent(new CustomEvent("readystatechange", {})));
|
|
40
28
|
}
|
|
29
|
+
#n = r.UNSENT;
|
|
41
30
|
get status() {
|
|
42
|
-
return
|
|
31
|
+
return this.#t ? this.#n : super.status;
|
|
43
32
|
}
|
|
33
|
+
#i = "";
|
|
44
34
|
get statusText() {
|
|
45
|
-
return
|
|
35
|
+
return this.#t ? this.#i : super.statusText;
|
|
46
36
|
}
|
|
37
|
+
#e = r.UNSENT;
|
|
47
38
|
get readyState() {
|
|
48
|
-
return
|
|
39
|
+
return this.#t ? this.#e : super.readyState;
|
|
49
40
|
}
|
|
41
|
+
#r = null;
|
|
50
42
|
get response() {
|
|
51
|
-
return
|
|
43
|
+
return this.#t ? this.#r : super.response;
|
|
52
44
|
}
|
|
53
45
|
get responseText() {
|
|
54
46
|
let t = super.responseText;
|
|
55
|
-
if (
|
|
47
|
+
if (this.#t)
|
|
56
48
|
try {
|
|
57
49
|
t = JSON.stringify(this.response) ?? t;
|
|
58
|
-
} catch (
|
|
59
|
-
t = super.responseText, console.error(
|
|
50
|
+
} catch (e) {
|
|
51
|
+
t = super.responseText, console.error(e);
|
|
60
52
|
}
|
|
61
53
|
return t;
|
|
62
54
|
}
|
|
63
55
|
send(t) {
|
|
64
|
-
if (
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
67
|
-
|
|
56
|
+
if (this.#t)
|
|
57
|
+
if (this.#s.async) {
|
|
58
|
+
const e = setTimeout(() => {
|
|
59
|
+
this.#u(t), clearTimeout(e);
|
|
68
60
|
}, Math.random() * 227);
|
|
69
61
|
} else
|
|
70
|
-
|
|
62
|
+
this.#u(t);
|
|
71
63
|
else
|
|
72
64
|
super.send(t);
|
|
73
65
|
}
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
#u(t) {
|
|
67
|
+
this.setRequestHeader("X-Requested-With", "PqbMockXMLHttpRequest"), this.dispatchEvent(new CustomEvent("loadstart", {})), this.#e = r.HEADERS_RECEIVED, this.dispatchEvent(new CustomEvent("readystatechange", {})), this.#e = r.LOADING, this.dispatchEvent(new CustomEvent("readystatechange", {})), this.#n = 200, this.#i = "OK";
|
|
68
|
+
const e = this.#t?.template;
|
|
69
|
+
this.#r = e?.({ ...this.#s, body: t }) ?? e, this.#e = r.DONE, this.dispatchEvent(new CustomEvent("readystatechange", {})), this.dispatchEvent(new CustomEvent("load", {})), this.dispatchEvent(new CustomEvent("loadend", {}));
|
|
70
|
+
}
|
|
71
|
+
static add(t, e = "", n, s) {
|
|
72
|
+
t && (window.XMLHttpRequest = h, o[t + e] = {
|
|
76
73
|
url: t,
|
|
77
|
-
method:
|
|
78
|
-
template:
|
|
79
|
-
...
|
|
74
|
+
method: e,
|
|
75
|
+
template: n,
|
|
76
|
+
...s
|
|
80
77
|
});
|
|
81
78
|
}
|
|
82
|
-
}
|
|
83
|
-
o = new WeakMap(), l = new WeakMap(), g = new WeakMap(), w = new WeakMap(), p = new WeakMap(), v = new WeakMap(), C = new WeakSet(), x = function(t) {
|
|
84
|
-
var r;
|
|
85
|
-
this.setRequestHeader("X-Requested-With", "PqbMockXMLHttpRequest"), this.dispatchEvent(new CustomEvent("loadstart", {})), h(this, p, E.HEADERS_RECEIVED), this.dispatchEvent(new CustomEvent("readystatechange", {})), h(this, p, E.LOADING), this.dispatchEvent(new CustomEvent("readystatechange", {})), h(this, g, 200), h(this, w, "OK");
|
|
86
|
-
const s = (r = i(this, o)) == null ? void 0 : r.template;
|
|
87
|
-
h(this, v, (s == null ? void 0 : s({ ...i(this, l), body: t })) ?? s), h(this, p, E.DONE), this.dispatchEvent(new CustomEvent("readystatechange", {})), this.dispatchEvent(new CustomEvent("load", {})), this.dispatchEvent(new CustomEvent("loadend", {}));
|
|
88
|
-
};
|
|
89
|
-
let S = N;
|
|
79
|
+
}
|
|
90
80
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
h as MockXMLHttpRequest,
|
|
82
|
+
r as XMLHttpRequestNative,
|
|
83
|
+
h as default
|
|
94
84
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/utils","version":"0.1.
|
|
1
|
+
{"name":"@unicom-cloud/utils","version":"0.1.10","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/*","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
|
package/random/address.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import e from "lodash/sample";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
2
|
+
import o, { REGION as c } from "../constant/address.js";
|
|
3
|
+
import m from "./number.js";
|
|
4
|
+
const s = {
|
|
5
5
|
region() {
|
|
6
|
-
return e(
|
|
6
|
+
return e(c);
|
|
7
7
|
},
|
|
8
8
|
// 随机生成一个(中国)省(或直辖市、自治区、特别行政区)。
|
|
9
9
|
province() {
|
|
10
|
-
return e(
|
|
10
|
+
return e(o).name;
|
|
11
11
|
},
|
|
12
12
|
// 随机生成一个(中国)市。
|
|
13
13
|
city(t) {
|
|
14
|
-
const n = e(
|
|
14
|
+
const n = e(o), r = e(n?.children);
|
|
15
15
|
return t ? `${n.name} ${r.name}` : r.name;
|
|
16
16
|
},
|
|
17
17
|
// 随机生成一个(中国)县。
|
|
18
18
|
county(t) {
|
|
19
|
-
const n = e(
|
|
20
|
-
return t ? `${n.name} ${r.name} ${
|
|
19
|
+
const n = e(o), r = e(n?.children), i = e(r?.children);
|
|
20
|
+
return t ? `${n.name} ${r.name} ${i.name}` : i.name;
|
|
21
21
|
},
|
|
22
22
|
// 随机生成一个邮政编码(六位数字)。
|
|
23
23
|
zip(t) {
|
|
24
24
|
let n = "";
|
|
25
25
|
for (let r = 0; r < (t || 6); r++)
|
|
26
|
-
n +=
|
|
26
|
+
n += m.natural(0, 9);
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
s as default
|
|
32
32
|
};
|
package/screenfull/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const u = [
|
|
2
2
|
[
|
|
3
3
|
"requestFullscreen",
|
|
4
4
|
"exitFullscreen",
|
|
@@ -41,79 +41,79 @@ const o = [
|
|
|
41
41
|
// 'MSFullscreenChange',
|
|
42
42
|
// 'MSFullscreenError',
|
|
43
43
|
// ],
|
|
44
|
-
],
|
|
44
|
+
], l = Reflect.apply(
|
|
45
45
|
() => {
|
|
46
46
|
if (typeof document > "u")
|
|
47
47
|
return !1;
|
|
48
|
-
const
|
|
49
|
-
for (const
|
|
50
|
-
if (
|
|
51
|
-
for (const [
|
|
52
|
-
|
|
53
|
-
return
|
|
48
|
+
const n = u[0], t = {};
|
|
49
|
+
for (const e of u)
|
|
50
|
+
if (e?.[1] in document) {
|
|
51
|
+
for (const [c, o] of e.entries())
|
|
52
|
+
t[n[c]] = o;
|
|
53
|
+
return t;
|
|
54
54
|
}
|
|
55
55
|
return !1;
|
|
56
56
|
},
|
|
57
57
|
void 0,
|
|
58
58
|
[]
|
|
59
|
-
),
|
|
60
|
-
change:
|
|
61
|
-
error:
|
|
59
|
+
), i = {
|
|
60
|
+
change: l?.fullscreenchange,
|
|
61
|
+
error: l?.fullscreenerror
|
|
62
62
|
};
|
|
63
|
-
let
|
|
64
|
-
request(
|
|
65
|
-
return new Promise((
|
|
66
|
-
const
|
|
67
|
-
|
|
63
|
+
let r = {
|
|
64
|
+
request(n = document.documentElement, t) {
|
|
65
|
+
return new Promise((e, s) => {
|
|
66
|
+
const c = () => {
|
|
67
|
+
r.off("change", c), e();
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
69
|
+
r.on("change", c);
|
|
70
|
+
const o = n[l?.requestFullscreen](t);
|
|
71
|
+
o instanceof Promise && o.then(c).catch(s);
|
|
72
72
|
});
|
|
73
73
|
},
|
|
74
74
|
exit() {
|
|
75
|
-
return new Promise((
|
|
76
|
-
if (!
|
|
77
|
-
|
|
75
|
+
return new Promise((n, t) => {
|
|
76
|
+
if (!r.isFullscreen) {
|
|
77
|
+
n();
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const e = () => {
|
|
81
|
+
r.off("change", e), n();
|
|
82
82
|
};
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
83
|
+
r.on("change", e);
|
|
84
|
+
const s = document[l?.exitFullscreen]();
|
|
85
|
+
s instanceof Promise && s.then(e).catch(t);
|
|
86
86
|
});
|
|
87
87
|
},
|
|
88
|
-
toggle(
|
|
89
|
-
return
|
|
88
|
+
toggle(n, t) {
|
|
89
|
+
return r.isFullscreen ? r.exit() : r.request(n, t);
|
|
90
90
|
},
|
|
91
|
-
on(
|
|
92
|
-
const
|
|
93
|
-
|
|
91
|
+
on(n, t) {
|
|
92
|
+
const e = i[n];
|
|
93
|
+
e && document.addEventListener(e, t, !1);
|
|
94
94
|
},
|
|
95
|
-
off(
|
|
96
|
-
const
|
|
97
|
-
|
|
95
|
+
off(n, t) {
|
|
96
|
+
const e = i[n];
|
|
97
|
+
e && document.removeEventListener(e, t, !1);
|
|
98
98
|
},
|
|
99
|
-
raw:
|
|
99
|
+
raw: l
|
|
100
100
|
};
|
|
101
|
-
Object.defineProperties(
|
|
101
|
+
Object.defineProperties(r, {
|
|
102
102
|
isFullscreen: {
|
|
103
|
-
get: () => !!document[
|
|
103
|
+
get: () => !!document[l?.fullscreenElement]
|
|
104
104
|
},
|
|
105
105
|
element: {
|
|
106
106
|
enumerable: !0,
|
|
107
|
-
get: () => document[
|
|
107
|
+
get: () => document[l?.fullscreenElement] ?? void 0
|
|
108
108
|
},
|
|
109
109
|
isEnabled: {
|
|
110
110
|
enumerable: !0,
|
|
111
111
|
// Coerce to boolean in case of old WebKit.
|
|
112
|
-
get: () => !!document[
|
|
112
|
+
get: () => !!document[l?.fullscreenEnabled]
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
-
|
|
116
|
-
const
|
|
115
|
+
l || (r = { isEnabled: !1 });
|
|
116
|
+
const f = r;
|
|
117
117
|
export {
|
|
118
|
-
|
|
118
|
+
f as default
|
|
119
119
|
};
|
|
@@ -1,33 +1,47 @@
|
|
|
1
|
-
import { imageCache as
|
|
2
|
-
import { embedCustomFonts as
|
|
3
|
-
import { precacheCommonTags as
|
|
4
|
-
import { fetchImage as
|
|
5
|
-
async function
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { imageCache as i, bgCache as u, resourceCache as h, baseCSSCache as p } from "../core/cache.js";
|
|
2
|
+
import { embedCustomFonts as y } from "../modules/fonts.js";
|
|
3
|
+
import { precacheCommonTags as d } from "../utils/cssTools.js";
|
|
4
|
+
import { fetchImage as C, getStyle as S, splitBackgroundImage as b, inlineSingleBackgroundEntry as A } from "../utils/helpers.js";
|
|
5
|
+
async function w(o = document, f = {}) {
|
|
6
|
+
const {
|
|
7
|
+
embedFonts: a = !0,
|
|
8
|
+
reset: g = !1,
|
|
9
|
+
crossOrigin: s
|
|
10
|
+
} = f;
|
|
11
|
+
if (g) {
|
|
12
|
+
i.clear(), u.clear(), h.clear(), p.clear();
|
|
9
13
|
return;
|
|
10
14
|
}
|
|
11
|
-
await document.fonts.ready,
|
|
12
|
-
let l = [],
|
|
13
|
-
|
|
15
|
+
await document.fonts.ready, d();
|
|
16
|
+
let l = [], m = [];
|
|
17
|
+
o?.querySelectorAll && (l = Array.from(o.querySelectorAll("img[src]")), m = Array.from(o.querySelectorAll("*")));
|
|
14
18
|
const t = [];
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
for (const c of l) {
|
|
20
|
+
const r = c.src;
|
|
21
|
+
if (!i.has(r)) {
|
|
22
|
+
const n = s ? s(r) : "anonymous";
|
|
23
|
+
t.push(
|
|
24
|
+
C(r, 3e3, n).then((e) => i.set(r, e)).catch(() => {
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
|
-
for (const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
for (const c of m) {
|
|
30
|
+
const r = S(c).backgroundImage;
|
|
31
|
+
if (r && r !== "none") {
|
|
32
|
+
const n = b(r);
|
|
33
|
+
for (const e of n)
|
|
34
|
+
e.startsWith("url(") && t.push(
|
|
35
|
+
A(e, {
|
|
36
|
+
crossOrigin: s,
|
|
37
|
+
skipInline: !0
|
|
38
|
+
}).catch(() => {
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
|
-
|
|
43
|
+
a && await y({ ignoreIconFonts: !a, preCached: !0 }), await Promise.all(t);
|
|
30
44
|
}
|
|
31
45
|
export {
|
|
32
|
-
|
|
46
|
+
w as preCache
|
|
33
47
|
};
|