@unicom-cloud/utils 0.1.16 → 0.1.18
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/class-name/index.js +5 -5
- package/constant/index.js +24 -2
- package/constant/platform.js +13 -12
- package/constant.js +24 -2
- package/content-disposition/index.js +3 -3
- package/date/convertTime.js +4 -4
- package/diff/index.js +7 -0
- package/diff/src/diff.d.ts +21 -0
- package/diff/src/diff.js +381 -0
- package/diff.js +7 -0
- package/filesize/types/constants.d.ts +81 -0
- package/filesize/types/filesize.d.ts +97 -0
- package/index.js +68 -58
- package/js-cookie/index.d.ts +116 -0
- package/js-cookie/index.js +4 -0
- package/js-cookie/src/api.js +56 -0
- package/js-cookie/src/assign.js +11 -0
- package/js-cookie/src/converter.js +14 -0
- package/jsCookie.js +4 -0
- package/lunar/lib/HolidayUtil.js +48 -49
- package/mitt/index.js +4 -0
- package/mitt/src/index.js +37 -0
- package/mitt.js +4 -0
- package/nzh/nzh.d.ts +74 -0
- package/package.json +1 -1
- package/pinyin/index.js +4 -0
- package/pinyin/simplified.js +4 -0
- package/pinyin/src/core.js +143 -0
- package/pinyin/src/simplified.js +8 -0
- package/pinyin/src/simplified_dict.js +410 -0
- package/pinyin/src/traditional.js +8 -0
- package/pinyin/src/traditional_dict.js +403 -0
- package/pinyin/traditional.js +4 -0
- package/pinyin.js +4 -0
- package/query-string/base.d.ts +717 -0
- package/query-string/base.js +268 -0
- package/query-string/index.d.ts +16 -0
- package/query-string/index.js +4 -0
- package/query-string/splitOnFirst.js +14 -0
- package/queryString.js +4 -0
- package/random/index.js +56 -35
- package/snapdom/src/api/preCache.js +51 -28
- package/snapdom/src/core/cache.js +1 -4
- package/snapdom/src/core/capture.js +45 -44
- package/snapdom/src/core/clone.js +82 -66
- package/snapdom/src/core/prepare.js +167 -45
- package/snapdom/src/modules/background.js +29 -19
- package/snapdom/src/modules/fonts.js +158 -111
- package/snapdom/src/modules/images.js +14 -9
- package/snapdom/src/modules/pseudo.js +52 -47
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/modules/svgDefs.js +39 -20
- package/snapdom/src/utils/cssTools.js +58 -51
- package/snapdom/src/utils/helpers.js +197 -140
- package/snapdom/types/snapdom.d.ts +101 -0
- package/types/constant/index.d.ts +11 -0
- package/types/constant/platform.d.ts +1 -0
- package/types/diff/index.d.ts +2 -0
- package/types/diff/src/diff.d.ts +40 -0
- package/types/index.d.ts +6 -1
- package/types/js-cookie/index.d.ts +1 -0
- package/types/js-cookie/src/api.d.mts +2 -0
- package/types/js-cookie/src/assign.d.mts +1 -0
- package/types/js-cookie/src/converter.d.mts +5 -0
- package/types/mitt/index.d.ts +2 -0
- package/types/mitt/src/index.d.ts +29 -0
- package/types/pinyin/index.d.ts +1 -0
- package/types/pinyin/simplified.d.ts +1 -0
- package/types/pinyin/src/core.d.ts +3 -0
- package/types/pinyin/src/simplified.d.ts +4 -0
- package/types/pinyin/src/simplified_dict.d.ts +408 -0
- package/types/pinyin/src/traditional.d.ts +4 -0
- package/types/pinyin/src/traditional_dict.d.ts +401 -0
- package/types/pinyin/traditional.d.ts +1 -0
- package/types/query-string/base.d.ts +11 -0
- package/types/query-string/index.d.ts +2 -0
- package/types/query-string/splitOnFirst.d.ts +1 -0
- package/types/random/index.d.ts +14 -23
- package/types/snapdom/src/api/preCache.d.ts +2 -5
- package/types/snapdom/src/core/cache.d.ts +0 -3
- package/types/snapdom/src/core/clone.d.ts +1 -1
- package/types/snapdom/src/modules/background.d.ts +16 -6
- package/types/snapdom/src/modules/fonts.d.ts +5 -1
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
- package/types/snapdom/src/utils/cssTools.d.ts +2 -10
- package/types/snapdom/src/utils/helpers.d.ts +13 -7
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/url-toolkit/src/url-toolkit.d.ts +22 -0
- package/event-emitter/index.js +0 -48
- package/eventEmitter.js +0 -4
- package/types/event-emitter/index.d.ts +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cache as
|
|
1
|
+
import { cache as i } from "../core/cache.js";
|
|
2
2
|
const d = [
|
|
3
3
|
"div",
|
|
4
4
|
"span",
|
|
@@ -38,74 +38,81 @@ const d = [
|
|
|
38
38
|
"td",
|
|
39
39
|
"th"
|
|
40
40
|
];
|
|
41
|
-
function
|
|
42
|
-
for (let
|
|
43
|
-
|
|
41
|
+
function p() {
|
|
42
|
+
for (let t of d)
|
|
43
|
+
r(t);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
45
|
+
function r(t) {
|
|
46
|
+
if (i.defaultStyle.has(t))
|
|
47
|
+
return i.defaultStyle.get(t);
|
|
48
48
|
if ((/* @__PURE__ */ new Set([
|
|
49
49
|
"script",
|
|
50
50
|
"style",
|
|
51
51
|
"meta",
|
|
52
52
|
"link",
|
|
53
53
|
"noscript",
|
|
54
|
-
"template"
|
|
55
|
-
|
|
54
|
+
"template",
|
|
55
|
+
"defs",
|
|
56
|
+
"symbol",
|
|
57
|
+
"title",
|
|
58
|
+
"metadata",
|
|
59
|
+
"desc"
|
|
60
|
+
])).has(t)) {
|
|
56
61
|
const o = {};
|
|
57
|
-
return
|
|
62
|
+
return i.defaultStyle.set(t, o), o;
|
|
58
63
|
}
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const n = document.createElement(
|
|
62
|
-
n.style.all = "initial",
|
|
63
|
-
const
|
|
64
|
-
for (let o of
|
|
65
|
-
|
|
66
|
-
return
|
|
64
|
+
let e = document.getElementById("snapdom-sandbox");
|
|
65
|
+
e || (e = document.createElement("div"), e.id = "snapdom-sandbox", e.style.position = "absolute", e.style.left = "-9999px", e.style.top = "-9999px", e.style.width = "0", e.style.height = "0", e.style.overflow = "hidden", document.body.appendChild(e));
|
|
66
|
+
const n = document.createElement(t);
|
|
67
|
+
n.style.all = "initial", e.appendChild(n);
|
|
68
|
+
const l = getComputedStyle(n), a = {};
|
|
69
|
+
for (let o of l)
|
|
70
|
+
a[o] = l.getPropertyValue(o);
|
|
71
|
+
return e.removeChild(n), i.defaultStyle.set(t, a), a;
|
|
67
72
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const f = /* @__PURE__ */ new Set(["-webkit-locale"]);
|
|
74
|
+
function y(t, s, e = !1) {
|
|
75
|
+
const n = [], l = r(s);
|
|
76
|
+
for (let [a, o] of Object.entries(t))
|
|
77
|
+
if (!f.has(a))
|
|
78
|
+
if (!e)
|
|
79
|
+
o && n.push(`${a}:${o}`);
|
|
80
|
+
else {
|
|
81
|
+
const c = l[a];
|
|
82
|
+
o && o !== c && n.push(`${a}:${o}`);
|
|
83
|
+
}
|
|
77
84
|
return n.sort().join(";");
|
|
78
85
|
}
|
|
79
|
-
function
|
|
86
|
+
function h(t) {
|
|
80
87
|
const s = /* @__PURE__ */ new Set();
|
|
81
|
-
return
|
|
88
|
+
return t.nodeType !== Node.ELEMENT_NODE && t.nodeType !== Node.DOCUMENT_FRAGMENT_NODE ? [] : (t.tagName && s.add(t.tagName.toLowerCase()), typeof t.querySelectorAll == "function" && t.querySelectorAll("*").forEach((e) => s.add(e.tagName.toLowerCase())), Array.from(s));
|
|
82
89
|
}
|
|
83
|
-
function
|
|
90
|
+
function m(t) {
|
|
84
91
|
const s = /* @__PURE__ */ new Map();
|
|
85
|
-
for (let n of
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
const
|
|
89
|
-
s.has(
|
|
92
|
+
for (let n of t) {
|
|
93
|
+
const l = i.defaultStyle.get(n);
|
|
94
|
+
if (!l) continue;
|
|
95
|
+
const a = Object.entries(l).map(([o, c]) => `${o}:${c};`).sort().join("");
|
|
96
|
+
s.has(a) || s.set(a, []), s.get(a).push(n);
|
|
90
97
|
}
|
|
91
|
-
let
|
|
92
|
-
for (let [n,
|
|
93
|
-
|
|
98
|
+
let e = "";
|
|
99
|
+
for (let [n, l] of s.entries())
|
|
100
|
+
e += `${l.join(",")} { ${n} }
|
|
94
101
|
`;
|
|
95
|
-
return
|
|
102
|
+
return e;
|
|
96
103
|
}
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
let
|
|
100
|
-
for (const
|
|
101
|
-
|
|
102
|
-
return
|
|
104
|
+
function g(t) {
|
|
105
|
+
const s = new Set(t.values()), e = /* @__PURE__ */ new Map();
|
|
106
|
+
let n = 1;
|
|
107
|
+
for (const l of s)
|
|
108
|
+
l.trim() && e.set(l, `c${n++}`);
|
|
109
|
+
return e;
|
|
103
110
|
}
|
|
104
111
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
h as collectUsedTagNames,
|
|
113
|
+
g as generateCSSClasses,
|
|
114
|
+
m as generateDedupedBaseCSS,
|
|
115
|
+
r as getDefaultStyleForTag,
|
|
116
|
+
y as getStyleKey,
|
|
117
|
+
p as precacheCommonTags
|
|
111
118
|
};
|
|
@@ -1,183 +1,240 @@
|
|
|
1
|
-
import { cache as
|
|
2
|
-
async function
|
|
3
|
-
const n =
|
|
4
|
-
|
|
1
|
+
import { cache as d } from "../core/cache.js";
|
|
2
|
+
async function P(e, t = {}) {
|
|
3
|
+
const n = $(e), c = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(
|
|
4
|
+
e
|
|
5
5
|
);
|
|
6
6
|
if (n) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
7
|
+
const r = I(n);
|
|
8
|
+
if (d.background.has(r))
|
|
9
|
+
return t.skipInline ? void 0 : `url(${d.background.get(r)})`;
|
|
10
10
|
{
|
|
11
|
-
const
|
|
12
|
-
useProxy:
|
|
11
|
+
const l = await U(r, {
|
|
12
|
+
useProxy: t.useProxy
|
|
13
13
|
});
|
|
14
|
-
return
|
|
14
|
+
return d.background.set(r, l), t.skipInline ? void 0 : `url("${l}")`;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return e;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
"requestIdleCallback" in window ? requestIdleCallback(
|
|
19
|
+
function D(e, { fast: t = !1 } = {}) {
|
|
20
|
+
if (t) return e();
|
|
21
|
+
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 50 }) : setTimeout(e, 1);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!(
|
|
25
|
-
return window.getComputedStyle(
|
|
26
|
-
let n =
|
|
27
|
-
if (n || (n = /* @__PURE__ */ new Map(),
|
|
28
|
-
const
|
|
29
|
-
n.set(
|
|
23
|
+
function b(e, t = null) {
|
|
24
|
+
if (!(e instanceof Element))
|
|
25
|
+
return window.getComputedStyle(e, t);
|
|
26
|
+
let n = d.computedStyle.get(e);
|
|
27
|
+
if (n || (n = /* @__PURE__ */ new Map(), d.computedStyle.set(e, n)), !n.has(t)) {
|
|
28
|
+
const c = window.getComputedStyle(e, t);
|
|
29
|
+
n.set(t, c);
|
|
30
30
|
}
|
|
31
|
-
return n.get(
|
|
31
|
+
return n.get(t);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
33
|
+
function M(e) {
|
|
34
|
+
let t = e.replace(/^['"]|['"]$/g, "");
|
|
35
|
+
if (t.startsWith("\\"))
|
|
36
36
|
try {
|
|
37
|
-
return String.fromCharCode(parseInt(
|
|
37
|
+
return String.fromCharCode(parseInt(t.replace("\\", ""), 16));
|
|
38
38
|
} catch {
|
|
39
|
-
return
|
|
39
|
+
return t;
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return t;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
const n =
|
|
43
|
+
function $(e) {
|
|
44
|
+
const t = e.match(/url\((['"]?)(.*?)(\1)\)/);
|
|
45
|
+
if (!t) return null;
|
|
46
|
+
const n = t[2].trim();
|
|
47
47
|
return n.startsWith("#") ? null : n;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
function
|
|
49
|
+
async function O(e, { useProxy: t = "" } = {}) {
|
|
50
|
+
async function n(c) {
|
|
51
|
+
const r = await fetch(c);
|
|
52
|
+
if (!r.ok) throw new Error(`[snapdom] Failed to fetch resource: ${c}`);
|
|
53
|
+
return r;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return await n(e);
|
|
57
|
+
} catch (c) {
|
|
58
|
+
if (t && typeof t == "string") {
|
|
59
|
+
const r = t.replace(/\/$/, "") + I(e);
|
|
60
|
+
return n(r);
|
|
61
|
+
}
|
|
62
|
+
throw c;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var g = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
|
|
66
|
+
function U(e, { timeout: t = 3e3, useProxy: n = "", errorTTL: c = 8e3 } = {}) {
|
|
67
|
+
function r(o) {
|
|
51
68
|
try {
|
|
52
|
-
return new URL(
|
|
69
|
+
return new URL(o, window.location.href).origin === window.location.origin ? "use-credentials" : "anonymous";
|
|
53
70
|
} catch {
|
|
54
71
|
return "anonymous";
|
|
55
72
|
}
|
|
56
73
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(o) => new Promise((r, g) => {
|
|
63
|
-
const m = new FileReader();
|
|
64
|
-
m.onloadend = () => {
|
|
65
|
-
const f = m.result;
|
|
66
|
-
if (typeof f != "string" || !f.startsWith("data:image/")) {
|
|
67
|
-
g(new Error("Invalid image data URL"));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
r(f);
|
|
71
|
-
}, m.onerror = () => g(new Error("FileReader error")), m.readAsDataURL(o);
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
+
const l = (o) => ({ ok: !0, data: o }), h = (o) => ({
|
|
75
|
+
ok: !1,
|
|
76
|
+
error: o instanceof Error ? o : new Error(String(o))
|
|
77
|
+
});
|
|
78
|
+
function x(o) {
|
|
74
79
|
try {
|
|
75
|
-
return
|
|
76
|
-
|
|
80
|
+
return fetch(o, {
|
|
81
|
+
mode: "cors",
|
|
82
|
+
credentials: r(o) === "use-credentials" ? "include" : "omit"
|
|
83
|
+
}).then((s) => s.ok ? s.blob().then(
|
|
84
|
+
(u) => new Promise((i) => {
|
|
85
|
+
const f = new FileReader();
|
|
86
|
+
f.onloadend = () => {
|
|
87
|
+
const m = f.result;
|
|
88
|
+
typeof m != "string" || !m.startsWith("data:image/") ? i(h(new Error("Invalid image data URL"))) : i(l(m));
|
|
89
|
+
}, f.onerror = () => i(h(new Error("FileReader error"))), f.readAsDataURL(u);
|
|
90
|
+
})
|
|
91
|
+
) : h(new Error("HTTP " + s.status))).catch((s) => h(s));
|
|
92
|
+
} catch (s) {
|
|
93
|
+
return Promise.resolve(h(s));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function p(o) {
|
|
97
|
+
return x(o).then((s) => {
|
|
98
|
+
if (s.ok) return s;
|
|
77
99
|
if (n && typeof n == "string") {
|
|
78
|
-
const
|
|
100
|
+
const u = n.replace(/\/$/, "") + I(o);
|
|
101
|
+
return x(u).then((i) => i.ok ? i : h(
|
|
102
|
+
new Error(
|
|
103
|
+
"[SnapDOM - fetchImage] Fetch failed and no proxy provided"
|
|
104
|
+
)
|
|
105
|
+
));
|
|
106
|
+
}
|
|
107
|
+
return h(
|
|
108
|
+
new Error("[SnapDOM - fetchImage] Fetch failed and no proxy provided")
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const E = Date.now(), S = y.get(e);
|
|
113
|
+
if (S && S > E) {
|
|
114
|
+
const o = Promise.reject(
|
|
115
|
+
new Error("[SnapDOM - fetchImage] Recently failed (cooldown).")
|
|
116
|
+
);
|
|
117
|
+
return o.catch(() => {
|
|
118
|
+
}), o;
|
|
119
|
+
}
|
|
120
|
+
if (g.has(e)) return g.get(e);
|
|
121
|
+
const v = r(e);
|
|
122
|
+
if (d.image.has(e)) return Promise.resolve(d.image.get(e));
|
|
123
|
+
if (e.startsWith("data:image/"))
|
|
124
|
+
return d.image.set(e, e), Promise.resolve(e);
|
|
125
|
+
if (/\.svg(\?.*)?$/i.test(e)) {
|
|
126
|
+
const o = (async () => {
|
|
127
|
+
const s = await (async () => {
|
|
79
128
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
129
|
+
const i = await fetch(e, {
|
|
130
|
+
mode: "cors",
|
|
131
|
+
credentials: v === "use-credentials" ? "include" : "omit"
|
|
132
|
+
});
|
|
133
|
+
if (!i.ok) return h(new Error("HTTP " + i.status));
|
|
134
|
+
const f = await i.text();
|
|
135
|
+
return l(
|
|
136
|
+
`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`
|
|
84
137
|
);
|
|
138
|
+
} catch (i) {
|
|
139
|
+
return h(i);
|
|
85
140
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
141
|
+
})();
|
|
142
|
+
if (s.ok)
|
|
143
|
+
return d.image.set(e, s.data), s.data;
|
|
144
|
+
const u = await p(e);
|
|
145
|
+
return u.ok ? (d.image.set(e, u.data), u.data) : (y.set(e, E + c), Promise.reject(u.error));
|
|
146
|
+
})();
|
|
147
|
+
return g.set(e, o), o.finally(() => g.delete(e)), o.catch(() => {
|
|
148
|
+
}), o;
|
|
91
149
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
await o.decode();
|
|
111
|
-
const r = document.createElement("canvas");
|
|
112
|
-
r.width = o.width, r.height = o.height, r.getContext("2d").drawImage(o, 0, 0, r.width, r.height);
|
|
113
|
-
const m = r.toDataURL("image/png");
|
|
114
|
-
s.image.set(t, m), l(m);
|
|
115
|
-
} catch {
|
|
150
|
+
const w = new Promise((o, s) => {
|
|
151
|
+
let u = !1;
|
|
152
|
+
const i = new Image(), f = (a) => (R) => {
|
|
153
|
+
u || (u = !0, clearTimeout(C), i.onload = i.onerror = null, a(R));
|
|
154
|
+
}, m = (a) => {
|
|
155
|
+
d.image.set(e, a), o(a);
|
|
156
|
+
}, k = (a) => {
|
|
157
|
+
y.set(e, Date.now() + c), s(a);
|
|
158
|
+
}, C = setTimeout(
|
|
159
|
+
f(() => {
|
|
160
|
+
p(e).then((a) => {
|
|
161
|
+
a.ok ? m(a.data) : k(new Error("Image load timed out"));
|
|
162
|
+
});
|
|
163
|
+
}),
|
|
164
|
+
t
|
|
165
|
+
);
|
|
166
|
+
i.crossOrigin = v, i.onload = f(() => {
|
|
167
|
+
Promise.resolve(i.decode()).then(() => {
|
|
116
168
|
try {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
} catch
|
|
120
|
-
|
|
169
|
+
const a = document.createElement("canvas");
|
|
170
|
+
a.width = i.naturalWidth || i.width, a.height = i.naturalHeight || i.height, a.getContext("2d").drawImage(i, 0, 0, a.width, a.height), m(a.toDataURL("image/png"));
|
|
171
|
+
} catch {
|
|
172
|
+
p(e).then((a) => {
|
|
173
|
+
a.ok ? m(a.data) : k(a.error);
|
|
174
|
+
});
|
|
121
175
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
},
|
|
176
|
+
}).catch(() => {
|
|
177
|
+
p(e).then((a) => {
|
|
178
|
+
a.ok ? m(a.data) : k(a.error);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}), i.onerror = f(() => {
|
|
182
|
+
p(e).then((a) => {
|
|
183
|
+
a.ok ? m(a.data) : k(a.error);
|
|
184
|
+
});
|
|
185
|
+
}), i.src = e;
|
|
132
186
|
});
|
|
187
|
+
return g.set(e, w), w.finally(() => g.delete(e)), w.catch(() => {
|
|
188
|
+
}), w;
|
|
133
189
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
for (let n of
|
|
137
|
-
|
|
138
|
-
return
|
|
190
|
+
function T(e) {
|
|
191
|
+
const t = {};
|
|
192
|
+
for (let n of e)
|
|
193
|
+
t[n] = e.getPropertyValue(n);
|
|
194
|
+
return t;
|
|
139
195
|
}
|
|
140
|
-
function
|
|
196
|
+
function W() {
|
|
141
197
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
142
198
|
}
|
|
143
|
-
function
|
|
144
|
-
if (!
|
|
145
|
-
let
|
|
146
|
-
return
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
}),
|
|
150
|
-
const
|
|
151
|
-
return
|
|
152
|
-
}),
|
|
199
|
+
function L(e) {
|
|
200
|
+
if (!e || e === "none") return "";
|
|
201
|
+
let t = e.replace(/translate[XY]?\([^)]*\)/g, "");
|
|
202
|
+
return t = t.replace(/matrix\(([^)]+)\)/g, (n, c) => {
|
|
203
|
+
const r = c.split(",").map((l) => l.trim());
|
|
204
|
+
return r.length !== 6 ? `matrix(${c})` : (r[4] = "0", r[5] = "0", `matrix(${r.join(", ")})`);
|
|
205
|
+
}), t = t.replace(/matrix3d\(([^)]+)\)/g, (n, c) => {
|
|
206
|
+
const r = c.split(",").map((l) => l.trim());
|
|
207
|
+
return r.length !== 16 ? `matrix3d(${c})` : (r[12] = "0", r[13] = "0", `matrix3d(${r.join(", ")})`);
|
|
208
|
+
}), t.trim().replace(/\s{2,}/g, " ");
|
|
153
209
|
}
|
|
154
|
-
function
|
|
155
|
-
if (/%[0-9A-Fa-f]{2}/.test(
|
|
210
|
+
function I(e) {
|
|
211
|
+
if (/%[0-9A-Fa-f]{2}/.test(e)) return e;
|
|
156
212
|
try {
|
|
157
|
-
return encodeURI(
|
|
213
|
+
return encodeURI(e);
|
|
158
214
|
} catch {
|
|
159
|
-
return
|
|
215
|
+
return e;
|
|
160
216
|
}
|
|
161
217
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
let n = 0,
|
|
165
|
-
for (let
|
|
166
|
-
const
|
|
167
|
-
|
|
218
|
+
function j(e) {
|
|
219
|
+
const t = [];
|
|
220
|
+
let n = 0, c = 0;
|
|
221
|
+
for (let r = 0; r < e.length; r++) {
|
|
222
|
+
const l = e[r];
|
|
223
|
+
l === "(" && n++, l === ")" && n--, l === "," && n === 0 && (t.push(e.slice(c, r).trim()), c = r + 1);
|
|
168
224
|
}
|
|
169
|
-
return
|
|
225
|
+
return t.push(e.slice(c).trim()), t;
|
|
170
226
|
}
|
|
171
227
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
228
|
+
$ as extractURL,
|
|
229
|
+
U as fetchImage,
|
|
230
|
+
O as fetchResource,
|
|
231
|
+
b as getStyle,
|
|
232
|
+
D as idle,
|
|
233
|
+
P as inlineSingleBackgroundEntry,
|
|
234
|
+
W as isSafari,
|
|
235
|
+
M as parseContent,
|
|
236
|
+
I as safeEncodeURI,
|
|
237
|
+
T as snapshotComputedStyle,
|
|
238
|
+
j as splitBackgroundImage,
|
|
239
|
+
L as stripTranslate
|
|
183
240
|
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
declare module '@zumer/snapdom' {
|
|
2
|
+
export interface SnapOptions {
|
|
3
|
+
compress?: boolean;
|
|
4
|
+
embedFonts?: boolean;
|
|
5
|
+
localFonts?: Array<{
|
|
6
|
+
family: string;
|
|
7
|
+
src: string;
|
|
8
|
+
weight?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
}>;
|
|
11
|
+
iconFonts?: string | RegExp | Array<string | RegExp>;
|
|
12
|
+
fast?: boolean;
|
|
13
|
+
scale?: number;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
format?: 'png' | 'jpeg' | 'jpg' | 'webp' | 'svg';
|
|
18
|
+
type?: 'png' | 'jpeg' | 'jpg' | 'webp' | 'svg';
|
|
19
|
+
filename?: string;
|
|
20
|
+
dpr?: number;
|
|
21
|
+
quality?: number;
|
|
22
|
+
useProxy?: string;
|
|
23
|
+
exclude?: string[];
|
|
24
|
+
filter?: (element: Element, originalElement: Element) => boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SnapResult {
|
|
28
|
+
url: string;
|
|
29
|
+
options: SnapOptions;
|
|
30
|
+
toRaw(): string;
|
|
31
|
+
toImg(): Promise<HTMLImageElement>;
|
|
32
|
+
toCanvas(): Promise<HTMLCanvasElement>;
|
|
33
|
+
toBlob(options?: SnapOptions): Promise<Blob>;
|
|
34
|
+
toPng(options?: SnapOptions): Promise<HTMLImageElement>;
|
|
35
|
+
toJpg(options?: SnapOptions): Promise<HTMLImageElement>;
|
|
36
|
+
toWebp(options?: SnapOptions): Promise<HTMLImageElement>;
|
|
37
|
+
download(options?: SnapOptions): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Captura un elemento del DOM como imagen SVG + métodos de exportación.
|
|
42
|
+
*/
|
|
43
|
+
export function snapdom(
|
|
44
|
+
element: HTMLElement,
|
|
45
|
+
options?: SnapOptions,
|
|
46
|
+
): Promise<SnapResult>;
|
|
47
|
+
|
|
48
|
+
export namespace snapdom {
|
|
49
|
+
function capture(
|
|
50
|
+
element: HTMLElement,
|
|
51
|
+
options?: SnapOptions,
|
|
52
|
+
): Promise<SnapResult>;
|
|
53
|
+
function toRaw(
|
|
54
|
+
element: HTMLElement,
|
|
55
|
+
options?: SnapOptions,
|
|
56
|
+
): Promise<string>;
|
|
57
|
+
function toImg(
|
|
58
|
+
element: HTMLElement,
|
|
59
|
+
options?: SnapOptions,
|
|
60
|
+
): Promise<HTMLImageElement>;
|
|
61
|
+
function toCanvas(
|
|
62
|
+
element: HTMLElement,
|
|
63
|
+
options?: SnapOptions,
|
|
64
|
+
): Promise<HTMLCanvasElement>;
|
|
65
|
+
function toBlob(element: HTMLElement, options?: SnapOptions): Promise<Blob>;
|
|
66
|
+
function toPng(
|
|
67
|
+
element: HTMLElement,
|
|
68
|
+
options?: SnapOptions,
|
|
69
|
+
): Promise<HTMLImageElement>;
|
|
70
|
+
function toJpg(
|
|
71
|
+
element: HTMLElement,
|
|
72
|
+
options?: SnapOptions,
|
|
73
|
+
): Promise<HTMLImageElement>;
|
|
74
|
+
function toWebp(
|
|
75
|
+
element: HTMLElement,
|
|
76
|
+
options?: SnapOptions,
|
|
77
|
+
): Promise<HTMLImageElement>;
|
|
78
|
+
function download(
|
|
79
|
+
element: HTMLElement,
|
|
80
|
+
options?: SnapOptions,
|
|
81
|
+
): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Precarga imágenes, fondos y fuentes para acelerar capturas posteriores.
|
|
86
|
+
*/
|
|
87
|
+
export function preCache(
|
|
88
|
+
root?: Document | HTMLElement,
|
|
89
|
+
options?: {
|
|
90
|
+
embedFonts?: boolean;
|
|
91
|
+
useProxy?: string;
|
|
92
|
+
reset?: boolean;
|
|
93
|
+
localFonts?: Array<{
|
|
94
|
+
family: string;
|
|
95
|
+
src: string;
|
|
96
|
+
weight?: string;
|
|
97
|
+
style?: string;
|
|
98
|
+
}>;
|
|
99
|
+
},
|
|
100
|
+
): Promise<void>;
|
|
101
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
export * as date from "./address";
|
|
2
|
+
export * as chineseCharacters from "./chineseCharacters";
|
|
3
|
+
export * as constellations from "./constellations";
|
|
4
|
+
export * as domain from "./domain";
|
|
5
|
+
export * as identity from "./identity";
|
|
6
|
+
export * as keyboardCode from "./keyboardCode";
|
|
7
|
+
export * as licensePlate from "./licensePlate";
|
|
8
|
+
export * as name from "./name";
|
|
9
|
+
export * as platform from "./platform";
|
|
10
|
+
export * as protocol from "./protocol";
|
|
11
|
+
export * as ui from "./ui";
|
|
1
12
|
export const MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK: MediaQueryList;
|
|
@@ -6,6 +6,7 @@ export const isIOS_OS: boolean;
|
|
|
6
6
|
export const isAndroidOS: boolean;
|
|
7
7
|
export const isHarmony: boolean;
|
|
8
8
|
export const isMacOS: boolean;
|
|
9
|
+
export const isAppleDevice: boolean;
|
|
9
10
|
export const isWindowsOS: boolean;
|
|
10
11
|
export const isMobileDevice: boolean;
|
|
11
12
|
export const isPWA: boolean;
|