@unicom-cloud/utils 0.1.31 → 0.1.32
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/case-name/index.js +1 -1
- package/caseName.js +1 -1
- package/class-name/index.js +6 -5
- package/className.js +1 -1
- package/clipboard-copy/index.js +1 -1
- package/clipboardCopy.js +1 -1
- package/constant/address.js +1 -1
- package/constant/chineseCharacters.js +1 -1
- package/constant/constellations.js +1 -1
- package/constant/domain.js +1 -1
- package/constant/emoji.js +1 -1
- package/constant/identity.js +1 -1
- package/constant/index.js +1 -1
- package/constant/isMobile.js +7 -0
- package/constant/keyboardCode.js +1 -1
- package/constant/licensePlate.js +1 -1
- package/constant/name.js +1 -1
- package/constant/platform.js +18 -17
- package/constant/protocol.js +1 -1
- package/constant/string.js +1 -1
- package/constant/ui.js +1 -1
- package/constant.js +1 -1
- package/content-disposition/index.js +1 -1
- package/contentDisposition.js +1 -1
- package/cookie/index.js +1 -1
- package/cookie/src/api.js +1 -1
- package/cookie/src/assign.js +1 -1
- package/cookie/src/converter.js +1 -1
- package/cookie.js +1 -1
- package/date/convertTime.js +1 -1
- package/date/convertToDuration.js +1 -1
- package/date/index.js +1 -1
- package/date.js +1 -1
- package/decimal/decimal.js +1 -1
- package/decimal/index.js +1 -1
- package/decimal.js +1 -1
- package/dom-helpers/activeElement.js +1 -1
- package/dom-helpers/addClass.js +1 -1
- package/dom-helpers/addEventListener.js +1 -1
- package/dom-helpers/animate.js +1 -1
- package/dom-helpers/animationFrame.js +1 -1
- package/dom-helpers/attribute.js +1 -1
- package/dom-helpers/camelize.js +1 -1
- package/dom-helpers/camelizeStyle.js +1 -1
- package/dom-helpers/canUseDOM.js +1 -1
- package/dom-helpers/childElements.js +1 -1
- package/dom-helpers/childNodes.js +1 -1
- package/dom-helpers/clear.js +1 -1
- package/dom-helpers/closest.js +1 -1
- package/dom-helpers/collectElements.js +1 -1
- package/dom-helpers/collectSiblings.js +1 -1
- package/dom-helpers/contains.js +1 -1
- package/dom-helpers/css.js +1 -1
- package/dom-helpers/filterEventHandler.js +1 -1
- package/dom-helpers/getComputedStyle.js +1 -1
- package/dom-helpers/getScrollAccessor.js +1 -1
- package/dom-helpers/hasClass.js +1 -1
- package/dom-helpers/height.js +1 -1
- package/dom-helpers/hyphenate.js +1 -1
- package/dom-helpers/hyphenateStyle.js +1 -1
- package/dom-helpers/index.js +1 -1
- package/dom-helpers/insertAfter.js +1 -1
- package/dom-helpers/isDocument.js +1 -1
- package/dom-helpers/isInput.js +1 -1
- package/dom-helpers/isTransform.js +1 -1
- package/dom-helpers/isVisible.js +1 -1
- package/dom-helpers/isWindow.js +1 -1
- package/dom-helpers/listen.js +1 -1
- package/dom-helpers/matches.js +1 -1
- package/dom-helpers/nextUntil.js +1 -1
- package/dom-helpers/offset.js +1 -1
- package/dom-helpers/offsetParent.js +1 -1
- package/dom-helpers/ownerDocument.js +1 -1
- package/dom-helpers/ownerWindow.js +1 -1
- package/dom-helpers/parents.js +1 -1
- package/dom-helpers/position.js +1 -1
- package/dom-helpers/prepend.js +1 -1
- package/dom-helpers/querySelectorAll.js +1 -1
- package/dom-helpers/reflow.js +1 -1
- package/dom-helpers/remove.js +1 -1
- package/dom-helpers/removeClass.js +1 -1
- package/dom-helpers/removeEventListener.js +1 -1
- package/dom-helpers/scrollLeft.js +1 -1
- package/dom-helpers/scrollParent.js +1 -1
- package/dom-helpers/scrollTo.js +1 -1
- package/dom-helpers/scrollTop.js +1 -1
- package/dom-helpers/scrollbarSize.js +1 -1
- package/dom-helpers/siblings.js +1 -1
- package/dom-helpers/text.js +1 -1
- package/dom-helpers/toggleClass.js +1 -1
- package/dom-helpers/transitionEnd.js +1 -1
- package/dom-helpers/triggerEvent.js +1 -1
- package/dom-helpers/types.js +1 -1
- package/dom-helpers/width.js +1 -1
- package/domHelpers.js +1 -1
- package/emitter/index.js +1 -1
- package/emitter/src/index.js +1 -1
- package/emitter.js +1 -1
- package/file/fileToURL.js +1 -1
- package/file/index.js +1 -1
- package/file/saveAs.js +1 -1
- package/file.js +1 -1
- package/idb/index.js +1 -1
- package/idb.js +1 -1
- package/index.js +1 -1
- package/invariant/index.js +1 -1
- package/invariant.js +1 -1
- package/is/index.js +1 -1
- package/is.js +1 -1
- package/lunar/index.js +1 -1
- package/lunar/lib/Holiday.js +1 -1
- package/lunar/lib/HolidayUtil.js +1 -1
- package/lunar/lib/I18n.js +1 -1
- package/lunar/lib/JieQi.js +1 -1
- package/lunar/lib/Lunar.js +1 -1
- package/lunar/lib/LunarMonth.js +1 -1
- package/lunar/lib/LunarTime.js +1 -1
- package/lunar/lib/LunarUtil.js +1 -1
- package/lunar/lib/LunarYear.js +1 -1
- package/lunar/lib/ShouXingUtil.js +1 -1
- package/lunar/lib/Solar.js +1 -1
- package/lunar/lib/SolarHalfYear.js +1 -1
- package/lunar/lib/SolarMonth.js +1 -1
- package/lunar/lib/SolarSeason.js +1 -1
- package/lunar/lib/SolarUtil.js +1 -1
- package/lunar/lib/SolarWeek.js +1 -1
- package/lunar/lib/SolarYear.js +1 -1
- package/lunar/lib/index.js +1 -1
- package/lunar.js +1 -1
- package/math/index.js +1 -1
- package/math.js +1 -1
- package/md5/index.js +1 -1
- package/md5.js +1 -1
- package/mock/MockWebSocket.js +1 -1
- package/mock/MockXMLHttpRequest.js +1 -1
- package/mock/index.js +1 -1
- package/mock.js +1 -1
- package/normalize-wheel/ExecutionEnvironment.js +1 -1
- package/normalize-wheel/UserAgent_DEPRECATED.js +1 -1
- package/normalize-wheel/index.js +1 -1
- package/normalize-wheel/isEventSupported.js +1 -1
- package/normalizeWheel.js +1 -1
- package/number-to-chinese/index.js +1 -1
- package/numberToChinese.js +1 -1
- package/nzh/cn.js +1 -1
- package/nzh/hk.js +1 -1
- package/nzh/index.js +1 -1
- package/nzh/nzh.js +1 -1
- package/nzh/src/autoGet.js +1 -1
- package/nzh/src/index.js +1 -1
- package/nzh/src/langs/cn_b.js +1 -1
- package/nzh/src/langs/cn_s.js +1 -1
- package/nzh/src/langs/hk_b.js +1 -1
- package/nzh/src/langs/hk_s.js +1 -1
- package/nzh/src/utils.js +1 -1
- package/nzh.js +1 -1
- package/object-keys-sort/index.js +1 -1
- package/object-prototype-to-string-call/index.js +1 -1
- package/objectKeysSort.js +1 -1
- package/objectPrototypeToStringCall.js +1 -1
- package/package.json +1 -1
- package/pinyin/index.js +1 -1
- package/pinyin/simplified.js +1 -1
- package/pinyin/src/core.js +1 -1
- package/pinyin/src/simplified.js +1 -1
- package/pinyin/src/simplified_dict.js +1 -1
- package/pinyin/src/traditional.js +1 -1
- package/pinyin/src/traditional_dict.js +1 -1
- package/pinyin/traditional.js +1 -1
- package/pinyin.js +1 -1
- package/query-string/base.js +1 -1
- package/query-string/index.js +1 -1
- package/query-string/splitOnFirst.js +1 -1
- package/queryString.js +1 -1
- package/random/address.js +1 -1
- package/random/constellation.js +1 -1
- package/random/image.js +1 -1
- package/random/index.js +1 -1
- package/random/licensePlate.js +1 -1
- package/random/name.js +1 -1
- package/random/number.js +1 -1
- package/random/text.js +1 -1
- package/random/time.js +1 -1
- package/random/web.js +1 -1
- package/random.js +1 -1
- package/screenfull/index.js +1 -1
- package/screenfull.js +1 -1
- package/sleep/index.js +1 -1
- package/sleep.js +1 -1
- package/snapdom/index.js +1 -1
- package/snapdom/src/api/preCache.js +1 -1
- package/snapdom/src/api/snapdom.js +198 -153
- package/snapdom/src/core/cache.js +1 -1
- package/snapdom/src/core/capture.js +121 -326
- package/snapdom/src/core/clone.js +117 -266
- package/snapdom/src/core/context.js +1 -1
- package/snapdom/src/core/plugins.js +1 -1
- package/snapdom/src/core/prepare.js +48 -157
- package/snapdom/src/exporters/download.js +9 -10
- package/snapdom/src/exporters/toBlob.js +10 -15
- package/snapdom/src/exporters/toCanvas.js +72 -65
- package/snapdom/src/exporters/toImg.js +1 -1
- package/snapdom/src/modules/CSSVar.js +1 -1
- package/snapdom/src/modules/background.js +1 -1
- package/snapdom/src/modules/changeCSS.js +1 -1
- package/snapdom/src/modules/counter.js +1 -1
- package/snapdom/src/modules/fonts.js +118 -112
- package/snapdom/src/modules/iconFonts.js +133 -69
- package/snapdom/src/modules/images.js +36 -33
- package/snapdom/src/modules/lineClamp.js +1 -1
- package/snapdom/src/modules/pseudo.js +275 -161
- package/snapdom/src/modules/rasterize.js +6 -7
- package/snapdom/src/modules/snapFetch.js +1 -1
- package/snapdom/src/modules/styles.js +89 -67
- package/snapdom/src/modules/svgDefs.js +73 -60
- package/snapdom/src/utils/browser.js +13 -8
- package/snapdom/src/utils/capture.helpers.js +131 -0
- package/snapdom/src/utils/clone.helpers.js +283 -0
- package/snapdom/src/utils/css.js +1 -1
- package/snapdom/src/utils/helpers.js +1 -1
- package/snapdom/src/utils/image.js +15 -24
- package/snapdom/src/utils/prepare.helpers.js +8 -0
- package/snapdom/src/utils/transforms.helpers.js +211 -0
- package/snapdom.js +1 -1
- package/string/index.js +1 -1
- package/string.js +1 -1
- package/tinycolor/index.js +1 -1
- package/tinycolor/src/conversion.js +1 -1
- package/tinycolor/src/css-color-names.js +1 -1
- package/tinycolor/src/format-input.js +1 -1
- package/tinycolor/src/from-ratio.js +1 -1
- package/tinycolor/src/index.js +1 -1
- package/tinycolor/src/random.js +1 -1
- package/tinycolor/src/readability.js +1 -1
- package/tinycolor/src/to-ms-filter.js +1 -1
- package/tinycolor/src/utils.js +1 -1
- package/tinycolor.js +1 -1
- package/tree/index.js +1 -1
- package/tree/search/index.js +1 -1
- package/tree.js +1 -1
- package/tween/index.js +1 -1
- package/tween/src/easing.js +1 -1
- package/tween/src/tween.js +1 -1
- package/tween.js +1 -1
- package/types/constant/isMobile.d.ts +3 -0
- package/types/snapdom/src/api/snapdom.d.ts +10 -79
- package/types/snapdom/src/exporters/toCanvas.d.ts +11 -3
- package/types/snapdom/src/exporters/toJpg.d.ts +1 -0
- package/types/snapdom/src/exporters/toPng.d.ts +6 -0
- package/types/snapdom/src/exporters/toSvg.d.ts +1 -0
- package/types/snapdom/src/exporters/toWebp.d.ts +1 -0
- package/types/snapdom/src/modules/iconFonts.d.ts +7 -20
- package/types/snapdom/src/modules/pseudo.d.ts +18 -0
- package/types/snapdom/src/modules/rasterize.d.ts +6 -10
- package/types/snapdom/src/utils/browser.d.ts +0 -3
- package/types/snapdom/src/utils/capture.helpers.d.ts +45 -0
- package/types/snapdom/src/utils/clone.helpers.d.ts +97 -0
- package/types/snapdom/src/utils/image.d.ts +0 -8
- package/types/snapdom/src/utils/index.d.ts +1 -1
- package/types/snapdom/src/utils/prepare.helpers.d.ts +9 -0
- package/types/snapdom/src/utils/transforms.helpers.d.ts +118 -0
- package/ui-color/compareColorByRange.js +1 -1
- package/ui-color/index.js +1 -1
- package/uiColor.js +1 -1
- package/url-toolkit/index.js +1 -1
- package/url-toolkit/src/url-toolkit.js +1 -1
- package/urlToolkit.js +1 -1
- package/validate/index.js +1 -1
- package/validate/src/index.js +1 -1
- package/validate/src/locale/en-US.js +1 -1
- package/validate/src/locale/zh-CN.js +1 -1
- package/validate/src/message.js +1 -1
- package/validate/src/rules/array.js +1 -1
- package/validate/src/rules/base.js +1 -1
- package/validate/src/rules/boolean.js +1 -1
- package/validate/src/rules/custom.js +1 -1
- package/validate/src/rules/number.js +1 -1
- package/validate/src/rules/object.js +1 -1
- package/validate/src/rules/string.js +1 -1
- package/validate/src/rules/type.js +1 -1
- package/validate/src/utils.js +1 -1
- package/validate.js +1 -1
- package/version/index.js +1 -1
- package/version.js +1 -1
- package/xlsx/index.js +1 -1
- package/xlsx/xlsx.js +1 -1
- package/xlsx.js +1 -1
|
@@ -1,186 +1,77 @@
|
|
|
1
|
-
/* 2025-11-
|
|
2
|
-
import { cache as
|
|
3
|
-
import { freezeSticky as
|
|
4
|
-
import { inlinePseudoElements as
|
|
5
|
-
import { snapFetch as A } from "../modules/snapFetch.js";
|
|
1
|
+
/* 2025-11-27 12:11:03 */
|
|
2
|
+
import { cache as c } from "./cache.js";
|
|
3
|
+
import { freezeSticky as h } from "../modules/changeCSS.js";
|
|
4
|
+
import { inlinePseudoElements as g } from "../modules/pseudo.js";
|
|
6
5
|
import { inlineExternalDefsAndSymbols as C } from "../modules/svgDefs.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import { resolveBlobUrlsInTree as u } from "../utils/clone.helpers.js";
|
|
7
|
+
import { generateCSSClasses as w } from "../utils/css.js";
|
|
8
|
+
import { stripTranslate as S } from "../utils/helpers.js";
|
|
9
|
+
import { stabilizeLayout as E } from "../utils/prepare.helpers.js";
|
|
10
|
+
import { deepClone as M } from "./clone.js";
|
|
11
|
+
async function R(s, d = {}) {
|
|
12
|
+
const n = {
|
|
13
|
+
styleMap: c.session.styleMap,
|
|
14
|
+
styleCache: c.session.styleCache,
|
|
15
|
+
nodeMap: c.session.nodeMap
|
|
15
16
|
};
|
|
16
|
-
let
|
|
17
|
-
|
|
17
|
+
let t, i = "", y = "";
|
|
18
|
+
E(s);
|
|
18
19
|
try {
|
|
19
|
-
C(
|
|
20
|
+
C(s);
|
|
20
21
|
} catch (e) {
|
|
21
22
|
console.warn("inlineExternal defs or symbol failed:", e);
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
|
-
|
|
25
|
+
t = await M(s, n, d, s);
|
|
25
26
|
} catch (e) {
|
|
26
27
|
throw console.warn("deepClone failed:", e), e;
|
|
27
28
|
}
|
|
28
29
|
try {
|
|
29
|
-
await
|
|
30
|
+
await g(s, t, n, d);
|
|
30
31
|
} catch (e) {
|
|
31
32
|
console.warn("inlinePseudoElements failed:", e);
|
|
32
33
|
}
|
|
33
|
-
await
|
|
34
|
+
await u(t);
|
|
34
35
|
try {
|
|
35
|
-
const e =
|
|
36
|
-
for (const
|
|
37
|
-
y +=
|
|
36
|
+
const e = t.querySelectorAll("style[data-sd]");
|
|
37
|
+
for (const o of e)
|
|
38
|
+
y += o.textContent || "", o.remove();
|
|
38
39
|
} catch {
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
for (const [e,
|
|
41
|
+
const f = w(n.styleMap);
|
|
42
|
+
i = Array.from(f.entries()).map(([e, o]) => `.${o}{${e}}`).join(""), i = y + i;
|
|
43
|
+
for (const [e, o] of n.styleMap.entries()) {
|
|
43
44
|
if (e.tagName === "STYLE") continue;
|
|
44
45
|
if (e.getRootNode && e.getRootNode() instanceof ShadowRoot) {
|
|
45
|
-
e.setAttribute("style",
|
|
46
|
+
e.setAttribute("style", o.replace(/;/g, "; "));
|
|
46
47
|
continue;
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
49
|
+
const r = f.get(o);
|
|
50
|
+
r && e.classList.add(r);
|
|
51
|
+
const l = e.style?.backgroundImage, m = e.dataset?.snapdomHasIcon;
|
|
52
|
+
l && l !== "none" && (e.style.backgroundImage = l), m && (e.style.verticalAlign = "middle", e.style.display = "inline");
|
|
52
53
|
}
|
|
53
|
-
for (const [e,
|
|
54
|
-
const
|
|
55
|
-
if ((
|
|
54
|
+
for (const [e, o] of n.nodeMap.entries()) {
|
|
55
|
+
const r = o.scrollLeft, l = o.scrollTop;
|
|
56
|
+
if ((r || l) && e instanceof HTMLElement) {
|
|
56
57
|
e.style.overflow = "hidden", e.style.scrollbarWidth = "none", e.style.msOverflowStyle = "none";
|
|
57
|
-
const
|
|
58
|
-
for (
|
|
59
|
-
|
|
60
|
-
e.appendChild(
|
|
58
|
+
const a = document.createElement("div");
|
|
59
|
+
for (a.style.transform = `translate(${-r}px, ${-l}px)`, a.style.willChange = "transform", a.style.display = "inline-block", a.style.width = "100%"; e.firstChild; )
|
|
60
|
+
a.appendChild(e.firstChild);
|
|
61
|
+
e.appendChild(a);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const e =
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
for (const [e, l] of o.nodeMap.entries())
|
|
71
|
-
l.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
|
|
72
|
-
return { clone: s, classCSS: c, styleCache: o.styleCache };
|
|
73
|
-
}
|
|
74
|
-
function q(t) {
|
|
75
|
-
const r = getComputedStyle(t), o = r.outlineStyle, s = r.outlineWidth, c = r.borderStyle, y = r.borderWidth, n = o !== "none" && parseFloat(s) > 0, a = c === "none" || parseFloat(y) === 0;
|
|
76
|
-
n && a && (t.style.border = `${s} solid transparent`);
|
|
77
|
-
}
|
|
78
|
-
var p = /* @__PURE__ */ new Map();
|
|
79
|
-
async function m(t) {
|
|
80
|
-
if (h.resource?.has(t)) return h.resource.get(t);
|
|
81
|
-
if (p.has(t)) return p.get(t);
|
|
82
|
-
const r = (async () => {
|
|
83
|
-
const o = await A(t, { as: "dataURL", silent: !0 });
|
|
84
|
-
if (!o.ok || typeof o.data != "string")
|
|
85
|
-
throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);
|
|
86
|
-
return h.resource?.set(t, o.data), o.data;
|
|
87
|
-
})();
|
|
88
|
-
p.set(t, r);
|
|
89
|
-
try {
|
|
90
|
-
const o = await r;
|
|
91
|
-
return p.set(t, o), o;
|
|
92
|
-
} catch (o) {
|
|
93
|
-
throw p.delete(t), o;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
var L = /\bblob:[^)"'\s]+/g;
|
|
97
|
-
async function S(t) {
|
|
98
|
-
if (!t || t.indexOf("blob:") === -1) return t;
|
|
99
|
-
const r = Array.from(new Set(t.match(L) || []));
|
|
100
|
-
if (r.length === 0) return t;
|
|
101
|
-
let o = t;
|
|
102
|
-
for (const s of r)
|
|
103
|
-
try {
|
|
104
|
-
const c = await m(s);
|
|
105
|
-
o = o.split(s).join(c);
|
|
106
|
-
} catch {
|
|
107
|
-
}
|
|
108
|
-
return o;
|
|
109
|
-
}
|
|
110
|
-
function g(t) {
|
|
111
|
-
return typeof t == "string" && t.startsWith("blob:");
|
|
112
|
-
}
|
|
113
|
-
function v(t) {
|
|
114
|
-
return (t || "").split(",").map((r) => r.trim()).filter(Boolean).map((r) => {
|
|
115
|
-
const o = r.match(/^(\S+)(\s+.+)?$/);
|
|
116
|
-
return o ? { url: o[1], desc: o[2] || "" } : null;
|
|
117
|
-
}).filter(Boolean);
|
|
118
|
-
}
|
|
119
|
-
function $(t) {
|
|
120
|
-
return t.map((r) => r.desc ? `${r.url} ${r.desc.trim()}` : r.url).join(", ");
|
|
121
|
-
}
|
|
122
|
-
async function k(t) {
|
|
123
|
-
if (!t) return;
|
|
124
|
-
const r = t.querySelectorAll ? t.querySelectorAll("img") : [];
|
|
125
|
-
for (const n of r)
|
|
126
|
-
try {
|
|
127
|
-
const e = n.getAttribute("src") || n.currentSrc || "";
|
|
128
|
-
if (g(e)) {
|
|
129
|
-
const i = await m(e);
|
|
130
|
-
n.setAttribute("src", i);
|
|
131
|
-
}
|
|
132
|
-
const l = n.getAttribute("srcset");
|
|
133
|
-
if (l && l.includes("blob:")) {
|
|
134
|
-
const i = v(l);
|
|
135
|
-
let f = !1;
|
|
136
|
-
for (const d of i)
|
|
137
|
-
if (g(d.url))
|
|
138
|
-
try {
|
|
139
|
-
d.url = await m(d.url), f = !0;
|
|
140
|
-
} catch {
|
|
141
|
-
}
|
|
142
|
-
f && n.setAttribute("srcset", $(i));
|
|
143
|
-
}
|
|
144
|
-
} catch {
|
|
145
|
-
}
|
|
146
|
-
const o = t.querySelectorAll ? t.querySelectorAll("image") : [];
|
|
147
|
-
for (const n of o)
|
|
148
|
-
try {
|
|
149
|
-
const a = "http://www.w3.org/1999/xlink", e = n.getAttribute("href") || n.getAttributeNS?.(a, "href");
|
|
150
|
-
if (g(e)) {
|
|
151
|
-
const l = await m(e);
|
|
152
|
-
n.setAttribute("href", l), n.removeAttributeNS?.(a, "href");
|
|
153
|
-
}
|
|
154
|
-
} catch {
|
|
155
|
-
}
|
|
156
|
-
const s = t.querySelectorAll ? t.querySelectorAll("[style*='blob:']") : [];
|
|
157
|
-
for (const n of s)
|
|
158
|
-
try {
|
|
159
|
-
const a = n.getAttribute("style");
|
|
160
|
-
if (a && a.includes("blob:")) {
|
|
161
|
-
const e = await S(a);
|
|
162
|
-
n.setAttribute("style", e);
|
|
163
|
-
}
|
|
164
|
-
} catch {
|
|
165
|
-
}
|
|
166
|
-
const c = t.querySelectorAll ? t.querySelectorAll("style") : [];
|
|
167
|
-
for (const n of c)
|
|
168
|
-
try {
|
|
169
|
-
const a = n.textContent || "";
|
|
170
|
-
a.includes("blob:") && (n.textContent = await S(a));
|
|
171
|
-
} catch {
|
|
172
|
-
}
|
|
173
|
-
const y = ["poster"];
|
|
174
|
-
for (const n of y) {
|
|
175
|
-
const a = t.querySelectorAll ? t.querySelectorAll(`[${n}^='blob:']`) : [];
|
|
176
|
-
for (const e of a)
|
|
177
|
-
try {
|
|
178
|
-
const l = e.getAttribute(n);
|
|
179
|
-
g(l) && e.setAttribute(n, await m(l));
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
64
|
+
const p = t instanceof HTMLElement && t.firstElementChild instanceof HTMLElement ? t.firstElementChild : t;
|
|
65
|
+
if (h(s, p), s === n.nodeMap.get(t)) {
|
|
66
|
+
const e = n.styleCache.get(s) || window.getComputedStyle(s);
|
|
67
|
+
n.styleCache.set(s, e);
|
|
68
|
+
const o = S(e.transform);
|
|
69
|
+
t.style.margin = "0", t.style.top = "auto", t.style.left = "auto", t.style.right = "auto", t.style.bottom = "auto", t.style.animation = "none", t.style.transition = "none", t.style.willChange = "auto", t.style.float = "none", t.style.clear = "none", t.style.transform = o || "";
|
|
182
70
|
}
|
|
71
|
+
for (const [e, o] of n.nodeMap.entries())
|
|
72
|
+
o.tagName === "PRE" && (e.style.marginTop = "0", e.style.marginBlockStart = "0");
|
|
73
|
+
return { clone: t, classCSS: i, styleCache: n.styleCache };
|
|
183
74
|
}
|
|
184
75
|
export {
|
|
185
|
-
|
|
76
|
+
R as prepareClone
|
|
186
77
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/* 2025-11-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
async function k(t, a) {
|
|
1
|
+
/* 2025-11-27 12:11:03 */
|
|
2
|
+
import { toBlob as n } from "./toBlob.js";
|
|
3
|
+
import { toCanvas as l } from "./toCanvas.js";
|
|
4
|
+
async function b(c, a) {
|
|
6
5
|
if (a.dpr = 1, a.format === "svg") {
|
|
7
|
-
const m = await
|
|
8
|
-
|
|
6
|
+
const m = await n(c, { ...a, type: "svg" }), r = URL.createObjectURL(m), t = document.createElement("a");
|
|
7
|
+
t.href = r, t.download = a.filename, t.click(), URL.revokeObjectURL(r);
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
|
-
const
|
|
12
|
-
e.href =
|
|
10
|
+
const o = await l(c, a), e = document.createElement("a");
|
|
11
|
+
e.href = o.toDataURL(`image/${a.format}`, a.quality), e.download = a.filename, e.click();
|
|
13
12
|
}
|
|
14
13
|
export {
|
|
15
|
-
|
|
14
|
+
b as download
|
|
16
15
|
};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
/* 2025-11-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return new Blob([t], { type: "image/svg+xml" });
|
|
1
|
+
/* 2025-11-27 12:11:03 */
|
|
2
|
+
import { toCanvas as c } from "./toCanvas.js";
|
|
3
|
+
async function m(o, t) {
|
|
4
|
+
const n = t.type;
|
|
5
|
+
if (n === "svg") {
|
|
6
|
+
const e = decodeURIComponent(o.split(",")[1]);
|
|
7
|
+
return new Blob([e], { type: "image/svg+xml" });
|
|
9
8
|
}
|
|
10
|
-
const
|
|
9
|
+
const a = await c(o, t);
|
|
11
10
|
return new Promise(
|
|
12
|
-
(
|
|
13
|
-
(c) => t(c),
|
|
14
|
-
`image/${e}`,
|
|
15
|
-
o.quality
|
|
16
|
-
)
|
|
11
|
+
(e) => a.toBlob((s) => e(s), `image/${n}`, t.quality)
|
|
17
12
|
);
|
|
18
13
|
}
|
|
19
14
|
export {
|
|
20
|
-
|
|
15
|
+
m as toBlob
|
|
21
16
|
};
|
|
@@ -1,106 +1,113 @@
|
|
|
1
|
-
/* 2025-11-
|
|
2
|
-
import { isSafari as
|
|
3
|
-
function y(e) {
|
|
4
|
-
return typeof e == "string" && /^data:image\/svg\+xml/i.test(e);
|
|
5
|
-
}
|
|
1
|
+
/* 2025-11-27 12:11:03 */
|
|
2
|
+
import { isSafari as y } from "../utils/browser.js";
|
|
6
3
|
function S(e) {
|
|
7
|
-
|
|
8
|
-
return s >= 0 ? decodeURIComponent(e.slice(s + 1)) : "";
|
|
4
|
+
return typeof e == "string" && /^data:image\/svg\+xml/i.test(e);
|
|
9
5
|
}
|
|
10
6
|
function C(e) {
|
|
11
|
-
|
|
7
|
+
const n = e.indexOf(",");
|
|
8
|
+
return n >= 0 ? decodeURIComponent(e.slice(n + 1)) : "";
|
|
12
9
|
}
|
|
13
10
|
function v(e) {
|
|
14
|
-
|
|
15
|
-
for (let r = 0; r < e.length; r++) {
|
|
16
|
-
const o = e[r];
|
|
17
|
-
o === "(" && i++, o === ")" && (i = Math.max(0, i - 1)), o === ";" && i === 0 ? (s.push(t), t = "") : t += o;
|
|
18
|
-
}
|
|
19
|
-
return t.trim() && s.push(t), s.map((r) => r.trim()).filter(Boolean);
|
|
11
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;
|
|
20
12
|
}
|
|
21
13
|
function D(e) {
|
|
22
|
-
|
|
14
|
+
let n = [], t = "", i = 0;
|
|
15
|
+
for (let a = 0; a < e.length; a++) {
|
|
16
|
+
const o = e[a];
|
|
17
|
+
o === "(" && i++, o === ")" && (i = Math.max(0, i - 1)), o === ";" && i === 0 ? (n.push(t), t = "") : t += o;
|
|
18
|
+
}
|
|
19
|
+
return t.trim() && n.push(t), n.map((a) => a.trim()).filter(Boolean);
|
|
20
|
+
}
|
|
21
|
+
function k(e) {
|
|
22
|
+
const n = [];
|
|
23
23
|
let t = "", i = 0;
|
|
24
24
|
for (let o = 0; o < e.length; o++) {
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const c = e[o];
|
|
26
|
+
c === "(" && i++, c === ")" && (i = Math.max(0, i - 1)), c === "," && i === 0 ? (n.push(t.trim()), t = "") : t += c;
|
|
27
27
|
}
|
|
28
|
-
t.trim() &&
|
|
29
|
-
const
|
|
30
|
-
for (const o of
|
|
28
|
+
t.trim() && n.push(t.trim());
|
|
29
|
+
const a = [];
|
|
30
|
+
for (const o of n) {
|
|
31
31
|
if (/\binset\b/i.test(o)) continue;
|
|
32
|
-
const
|
|
33
|
-
let
|
|
34
|
-
const
|
|
35
|
-
|
|
32
|
+
const c = o.match(/-?\d+(?:\.\d+)?px/gi) || [], [s = "0px", r = "0px", u = "0px"] = c;
|
|
33
|
+
let l = o.replace(/-?\d+(?:\.\d+)?px/gi, "").replace(/\binset\b/gi, "").trim().replace(/\s{2,}/g, " ");
|
|
34
|
+
const p = !!l && l !== ",";
|
|
35
|
+
a.push(`drop-shadow(${s} ${r} ${u}${p ? ` ${l}` : ""})`);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return a.join(" ");
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
let t = null, i = null,
|
|
39
|
+
function b(e) {
|
|
40
|
+
const n = D(e);
|
|
41
|
+
let t = null, i = null, a = null;
|
|
42
42
|
const o = [];
|
|
43
|
-
for (const
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
|
|
43
|
+
for (const s of n) {
|
|
44
|
+
const r = s.indexOf(":");
|
|
45
|
+
if (r < 0) continue;
|
|
46
|
+
const u = s.slice(0, r).trim().toLowerCase(), l = s.slice(r + 1).trim();
|
|
47
|
+
u === "box-shadow" ? a = l : u === "filter" ? t = l : u === "-webkit-filter" ? i = l : o.push([u, l]);
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
|
|
49
|
+
if (a) {
|
|
50
|
+
const s = k(a);
|
|
51
|
+
s && (t = t ? `${t} ${s}` : s, i = i ? `${i} ${s}` : s);
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
return t &&
|
|
53
|
+
const c = [...o];
|
|
54
|
+
return t && c.push(["filter", t]), i && c.push(["-webkit-filter", i]), c.map(([s, r]) => `${s}:${r}`).join(";");
|
|
55
55
|
}
|
|
56
56
|
function F(e) {
|
|
57
57
|
return e.replace(
|
|
58
58
|
/([^{}]+)\{([^}]*)\}/g,
|
|
59
|
-
(
|
|
59
|
+
(n, t, i) => `${t}{${b(i)}}`
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
function H(e) {
|
|
63
63
|
return e = e.replace(
|
|
64
64
|
/<style[^>]*>([\s\S]*?)<\/style>/gi,
|
|
65
|
-
(
|
|
65
|
+
(n, t) => n.replace(t, F(t))
|
|
66
66
|
), e = e.replace(
|
|
67
67
|
/style=(['"])([\s\S]*?)\1/gi,
|
|
68
|
-
(
|
|
68
|
+
(n, t, i) => `style=${t}${b(i)}${t}`
|
|
69
69
|
), e;
|
|
70
70
|
}
|
|
71
71
|
function M(e) {
|
|
72
|
-
if (!
|
|
72
|
+
if (!y() || !S(e)) return e;
|
|
73
73
|
try {
|
|
74
|
-
const
|
|
75
|
-
return
|
|
74
|
+
const n = C(e), t = H(n);
|
|
75
|
+
return v(t);
|
|
76
76
|
} catch {
|
|
77
77
|
return e;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
81
|
-
let {
|
|
80
|
+
async function W(e, n) {
|
|
81
|
+
let {
|
|
82
|
+
width: t,
|
|
83
|
+
height: i,
|
|
84
|
+
scale: a = 1,
|
|
85
|
+
dpr: o = 1,
|
|
86
|
+
meta: c = {},
|
|
87
|
+
backgroundColor: s
|
|
88
|
+
} = n;
|
|
82
89
|
e = M(e);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
let
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
else if (
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
} else if (
|
|
94
|
-
const
|
|
95
|
-
|
|
90
|
+
const r = new Image();
|
|
91
|
+
r.loading = "eager", r.decoding = "sync", r.crossOrigin = "anonymous", r.src = e, await r.decode();
|
|
92
|
+
const u = r.naturalWidth, l = r.naturalHeight, p = Number.isFinite(c.w0) ? c.w0 : u, x = Number.isFinite(c.h0) ? c.h0 : l;
|
|
93
|
+
let f, h;
|
|
94
|
+
const w = Number.isFinite(t), $ = Number.isFinite(i);
|
|
95
|
+
if (w && $)
|
|
96
|
+
f = Math.max(1, t), h = Math.max(1, i);
|
|
97
|
+
else if (w) {
|
|
98
|
+
const g = t / Math.max(1, p);
|
|
99
|
+
f = t, h = x * g;
|
|
100
|
+
} else if ($) {
|
|
101
|
+
const g = i / Math.max(1, x);
|
|
102
|
+
h = i, f = p * g;
|
|
96
103
|
} else
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
f = u, h = l;
|
|
105
|
+
f = f * a, h = h * a;
|
|
99
106
|
const d = document.createElement("canvas");
|
|
100
|
-
d.width =
|
|
101
|
-
const
|
|
102
|
-
return o !== 1 &&
|
|
107
|
+
d.width = f * o, d.height = h * o, d.style.width = `${f}px`, d.style.height = `${h}px`;
|
|
108
|
+
const m = d.getContext("2d");
|
|
109
|
+
return o !== 1 && m.scale(o, o), s && (m.save(), m.fillStyle = s, m.fillRect(0, 0, f, h), m.restore()), m.drawImage(r, 0, 0, f, h), d;
|
|
103
110
|
}
|
|
104
111
|
export {
|
|
105
|
-
|
|
112
|
+
W as toCanvas
|
|
106
113
|
};
|