@unicom-cloud/utils 0.1.31 → 0.1.33
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 +5 -5
- package/date.js +5 -5
- 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/getElementCoordinates.js +46 -0
- 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 +87 -84
- 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 +2 -2
- package/dom-helpers/triggerEvent.js +1 -1
- package/dom-helpers/types.js +1 -1
- package/dom-helpers/width.js +1 -1
- package/domHelpers.js +65 -63
- package/emitter/index.js +1 -1
- package/emitter/src/index.js +1 -1
- package/emitter.js +1 -1
- package/escape/index.js +11 -0
- package/escape.js +6 -0
- 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 +196 -141
- package/is/lib/isAscii.js +9 -0
- package/is/lib/isBase64.js +13 -0
- package/is/lib/isChinese.js +19 -0
- package/is/lib/isDataURI.js +25 -0
- package/is/lib/isEmail.js +72 -0
- package/is/lib/isFQDN.js +21 -0
- package/is/lib/isFullWidth.js +10 -0
- package/is/lib/isHSL.js +11 -0
- package/is/lib/isHalfWidth.js +10 -0
- package/is/lib/isHash.js +23 -0
- package/is/lib/isHexColor.js +12 -0
- package/is/lib/isIMEI.js +19 -0
- package/is/lib/isIP.js +21 -0
- package/is/lib/isIPRange.js +25 -0
- package/is/lib/isIdentityCard.js +190 -0
- package/is/lib/isJWT.js +14 -0
- package/is/lib/isMACAddress.js +9 -0
- package/is/lib/isMD5.js +9 -0
- package/is/lib/isMimeType.js +9 -0
- package/is/lib/isMobilePhone.js +192 -0
- package/is/lib/isPort.js +7 -0
- package/is/lib/isRgbColor.js +18 -0
- package/is/lib/isSemVer.js +20 -0
- package/is/lib/isSlug.js +9 -0
- package/is/lib/isStrongPassword.js +48 -0
- package/is/lib/isURL.js +78 -0
- package/is/lib/isUUID.js +24 -0
- package/is/lib/isVariableWidth.js +10 -0
- package/is/lib/util/assertString.js +12 -0
- package/is.js +122 -66
- 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 +2 -2
- 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 +6 -6
- package/pinyin/src/simplified_dict.js +5 -4
- package/pinyin/src/traditional.js +4 -4
- package/pinyin/src/traditional_dict.js +4 -3
- 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 +15 -11
- 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 +12 -11
- package/tinycolor/src/index.js +1 -1
- package/tinycolor/src/random.js +30 -29
- 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 +54 -75
- package/tree/search/index.js +1 -1
- package/tree.js +9 -11
- package/tween/index.js +1 -1
- package/tween/src/easing.js +1 -1
- package/tween/src/tween.js +15 -14
- package/tween.js +1 -1
- package/types/constant/isMobile.d.ts +3 -0
- package/types/date/index.d.ts +3 -3
- package/types/dom-helpers/getElementCoordinates.d.ts +40 -0
- package/types/dom-helpers/index.d.ts +3 -1
- package/types/escape/index.d.ts +2 -0
- package/types/is/index.d.ts +28 -1
- package/types/is/lib/isAscii.d.ts +1 -0
- package/types/is/lib/isBase64.d.ts +1 -0
- package/types/is/lib/isChinese.d.ts +4 -0
- package/types/is/lib/isDataURI.d.ts +1 -0
- package/types/is/lib/isEmail.d.ts +1 -0
- package/types/is/lib/isFQDN.d.ts +1 -0
- package/types/is/lib/isFullWidth.d.ts +2 -0
- package/types/is/lib/isHSL.d.ts +1 -0
- package/types/is/lib/isHalfWidth.d.ts +2 -0
- package/types/is/lib/isHash.d.ts +1 -0
- package/types/is/lib/isHexColor.d.ts +1 -0
- package/types/is/lib/isIMEI.d.ts +1 -0
- package/types/is/lib/isIP.d.ts +1 -0
- package/types/is/lib/isIPRange.d.ts +1 -0
- package/types/is/lib/isIdentityCard.d.ts +1 -0
- package/types/is/lib/isJWT.d.ts +1 -0
- package/types/is/lib/isMACAddress.d.ts +1 -0
- package/types/is/lib/isMD5.d.ts +1 -0
- package/types/is/lib/isMimeType.d.ts +1 -0
- package/types/is/lib/isMobilePhone.d.ts +2 -0
- package/types/is/lib/isOctal.d.ts +1 -0
- package/types/is/lib/isPort.d.ts +1 -0
- package/types/is/lib/isRgbColor.d.ts +1 -0
- package/types/is/lib/isSemVer.d.ts +1 -0
- package/types/is/lib/isSlug.d.ts +1 -0
- package/types/is/lib/isStrongPassword.d.ts +1 -0
- package/types/is/lib/isURL.d.ts +1 -0
- package/types/is/lib/isUUID.d.ts +1 -0
- package/types/is/lib/isVariableWidth.d.ts +1 -0
- package/types/is/lib/util/assertString.d.ts +1 -0
- package/types/pinyin/es/main.d.ts +4 -0
- package/types/pinyin/es/traditional.d.ts +4 -0
- package/types/snapdom/src/api/snapdom.d.ts +11 -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/types/tree/index.d.ts +3 -4
- package/types/validate/src/index.d.ts +23 -25
- package/types/validate/src/interface.d.ts +5 -3
- package/types/validate/src/locale/en-US.d.ts +12 -2
- package/types/validate/src/locale/index.d.ts +171 -0
- package/types/validate/src/locale/zh-CN.d.ts +12 -2
- package/types/validate/src/rules/base.d.ts +3 -1
- package/types/validate/src/rules/custom.d.ts +1 -1
- package/types/validate/src/rules/type.d.ts +10 -0
- package/ui-color/compareColorByRange.js +1 -1
- package/ui-color/index.js +8 -7
- package/uiColor.js +25 -24
- 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 +23 -25
- package/validate/src/index.js +116 -73
- package/validate/src/locale/en-US.js +12 -2
- package/validate/src/locale/index.js +11 -0
- package/validate/src/locale/zh-CN.js +12 -2
- package/validate/src/rules/array.js +2 -2
- package/validate/src/rules/base.js +35 -31
- package/validate/src/rules/boolean.js +1 -1
- package/validate/src/rules/custom.js +2 -2
- package/validate/src/rules/number.js +1 -1
- package/validate/src/rules/object.js +1 -1
- package/validate/src/rules/string.js +6 -5
- package/validate/src/rules/type.js +84 -14
- package/validate.js +23 -25
- package/version/index.js +1 -1
- package/version.js +1 -1
- package/xlsx/index.d.ts +4 -8
- package/xlsx/index.js +1 -1
- package/xlsx/xlsx.js +2 -2
- package/xlsx.js +1 -1
- package/types/validate/src/message.d.ts +0 -2
- package/types/validate/src/utils.d.ts +0 -3
- package/validate/src/message.js +0 -5
- package/validate/src/utils.js +0 -8
|
@@ -1,253 +1,96 @@
|
|
|
1
|
-
/* 2025-
|
|
2
|
-
import { resolveCSSVars as
|
|
3
|
-
import { inlineAllStyles as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
function
|
|
7
|
-
return Promise.all(
|
|
8
|
-
t.map((e) => new Promise((o) => {
|
|
9
|
-
function s() {
|
|
10
|
-
M(
|
|
11
|
-
(l) => {
|
|
12
|
-
(l && typeof l.timeRemaining == "function" ? l.timeRemaining() > 0 : !0) ? r(e, o) : s();
|
|
13
|
-
},
|
|
14
|
-
{ fast: n }
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
s();
|
|
18
|
-
}))
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
function R(t) {
|
|
22
|
-
return t = t.trim(), !t || /:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t) ? t : `${t}:not([data-sd-slotted])`;
|
|
23
|
-
}
|
|
24
|
-
function C(t, r, n = !0) {
|
|
25
|
-
return t.split(",").map((e) => e.trim()).filter(Boolean).map((e) => {
|
|
26
|
-
if (e.startsWith(":where(") || e.startsWith("@")) return e;
|
|
27
|
-
const o = n ? R(e) : e;
|
|
28
|
-
return `:where(${r} ${o})`;
|
|
29
|
-
}).join(", ");
|
|
30
|
-
}
|
|
31
|
-
function T(t, r) {
|
|
32
|
-
return t ? (t = t.replace(/:host\(([^)]+)\)/g, (n, e) => `:where(${r}:is(${e.trim()}))`), t = t.replace(/:host\b/g, `:where(${r})`), t = t.replace(/:host-context\(([^)]+)\)/g, (n, e) => `:where(:where(${e.trim()}) ${r})`), t = t.replace(/::slotted\(([^)]+)\)/g, (n, e) => `:where(${r} ${e.trim()})`), t = t.replace(
|
|
33
|
-
/(^|})(\s*)([^@}{]+){/g,
|
|
34
|
-
(n, e, o, s) => {
|
|
35
|
-
const l = C(
|
|
36
|
-
s,
|
|
37
|
-
r,
|
|
38
|
-
/*excludeSlotted*/
|
|
39
|
-
!0
|
|
40
|
-
);
|
|
41
|
-
return `${e}${o}${l}{`;
|
|
42
|
-
}
|
|
43
|
-
), t) : "";
|
|
44
|
-
}
|
|
45
|
-
function k(t) {
|
|
46
|
-
return t.shadowScopeSeq = (t.shadowScopeSeq || 0) + 1, `s${t.shadowScopeSeq}`;
|
|
47
|
-
}
|
|
48
|
-
function L(t) {
|
|
49
|
-
let r = "";
|
|
50
|
-
try {
|
|
51
|
-
t.querySelectorAll("style").forEach((e) => {
|
|
52
|
-
r += (e.textContent || "") + `
|
|
53
|
-
`;
|
|
54
|
-
});
|
|
55
|
-
const n = t.adoptedStyleSheets || [];
|
|
56
|
-
for (const e of n)
|
|
57
|
-
try {
|
|
58
|
-
if (e && e.cssRules)
|
|
59
|
-
for (const o of e.cssRules) r += o.cssText + `
|
|
60
|
-
`;
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
return r;
|
|
66
|
-
}
|
|
67
|
-
function I(t, r, n) {
|
|
68
|
-
if (!r) return;
|
|
69
|
-
const e = document.createElement("style");
|
|
70
|
-
e.setAttribute("data-sd", n), e.textContent = r, t.insertBefore(e, t.firstChild || null);
|
|
71
|
-
}
|
|
72
|
-
function W(t, r) {
|
|
73
|
-
try {
|
|
74
|
-
const n = t.currentSrc || t.src || "";
|
|
75
|
-
if (!n) return;
|
|
76
|
-
r.setAttribute("src", n), r.removeAttribute("srcset"), r.removeAttribute("sizes"), r.loading = "eager", r.decoding = "sync";
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function D(t) {
|
|
81
|
-
const r = /* @__PURE__ */ new Set();
|
|
82
|
-
if (!t) return r;
|
|
83
|
-
const n = /var\(\s*(--[A-Za-z0-9_-]+)\b/g;
|
|
84
|
-
let e;
|
|
85
|
-
for (; e = n.exec(t); ) r.add(e[1]);
|
|
86
|
-
return r;
|
|
87
|
-
}
|
|
88
|
-
function F(t, r) {
|
|
89
|
-
try {
|
|
90
|
-
let e = getComputedStyle(t).getPropertyValue(r).trim();
|
|
91
|
-
if (e) return e;
|
|
92
|
-
} catch {
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
let e = getComputedStyle(document.documentElement).getPropertyValue(r).trim();
|
|
96
|
-
if (e) return e;
|
|
97
|
-
} catch {
|
|
98
|
-
}
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
function H(t, r, n) {
|
|
102
|
-
const e = [];
|
|
103
|
-
for (const o of r) {
|
|
104
|
-
const s = F(t, o);
|
|
105
|
-
s && e.push(`${o}: ${s};`);
|
|
106
|
-
}
|
|
107
|
-
return e.length ? `${n}{${e.join("")}}
|
|
108
|
-
` : "";
|
|
109
|
-
}
|
|
110
|
-
function P(t) {
|
|
111
|
-
t && (t.nodeType === Node.ELEMENT_NODE && t.setAttribute("data-sd-slotted", ""), t.querySelectorAll && t.querySelectorAll("*").forEach((r) => r.setAttribute("data-sd-slotted", "")));
|
|
112
|
-
}
|
|
113
|
-
async function B(t, r = 3) {
|
|
114
|
-
const n = () => {
|
|
115
|
-
try {
|
|
116
|
-
return t.contentDocument || t.contentWindow?.document || null;
|
|
117
|
-
} catch {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
let e = n(), o = 0;
|
|
122
|
-
for (; o < r && (!e || !e.body && !e.documentElement); )
|
|
123
|
-
await new Promise((s) => setTimeout(s, 0)), e = n(), o++;
|
|
124
|
-
return e && (e.body || e.documentElement) ? e : null;
|
|
125
|
-
}
|
|
126
|
-
function _(t) {
|
|
127
|
-
const r = t.getBoundingClientRect();
|
|
128
|
-
let n = 0, e = 0, o = 0, s = 0;
|
|
129
|
-
try {
|
|
130
|
-
const f = getComputedStyle(t);
|
|
131
|
-
n = parseFloat(f.borderLeftWidth) || 0, e = parseFloat(f.borderRightWidth) || 0, o = parseFloat(f.borderTopWidth) || 0, s = parseFloat(f.borderBottomWidth) || 0;
|
|
132
|
-
} catch {
|
|
133
|
-
}
|
|
134
|
-
const l = Math.max(0, Math.round(r.width - (n + e))), h = Math.max(0, Math.round(r.height - (o + s)));
|
|
135
|
-
return { contentWidth: l, contentHeight: h, rect: r };
|
|
136
|
-
}
|
|
137
|
-
function q(t, r, n) {
|
|
138
|
-
const e = t.createElement("style");
|
|
139
|
-
return e.setAttribute("data-sd-iframe-pin", ""), e.textContent = `html, body {margin: 0 !important;padding: 0 !important;width: ${r}px !important;height: ${n}px !important;min-width: ${r}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`, (t.head || t.documentElement).appendChild(e), () => {
|
|
140
|
-
try {
|
|
141
|
-
e.remove();
|
|
142
|
-
} catch {
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
async function z(t, r, n) {
|
|
147
|
-
const e = await B(t, 3);
|
|
148
|
-
if (!e) throw new Error("iframe document not accessible/ready");
|
|
149
|
-
const { contentWidth: o, contentHeight: s, rect: l } = _(t), h = n?.snap;
|
|
150
|
-
if (!h || typeof h.toPng != "function")
|
|
151
|
-
throw new Error("snapdom.toPng not available in iframe or window");
|
|
152
|
-
const f = { ...n, scale: 1 }, i = q(e, o, s);
|
|
153
|
-
let a;
|
|
154
|
-
try {
|
|
155
|
-
a = await h.toPng(e.documentElement, f);
|
|
156
|
-
} finally {
|
|
157
|
-
i();
|
|
158
|
-
}
|
|
159
|
-
a.style.display = "block", a.style.width = `${o}px`, a.style.height = `${s}px`;
|
|
160
|
-
const c = document.createElement("div");
|
|
161
|
-
return r.nodeMap.set(c, t), b(t, c, r, n), c.style.overflow = "hidden", c.style.display = "block", c.style.width || (c.style.width = `${Math.round(l.width)}px`), c.style.height || (c.style.height = `${Math.round(l.height)}px`), c.appendChild(a), c;
|
|
162
|
-
}
|
|
163
|
-
async function A(t, r, n) {
|
|
1
|
+
/* 2025-12-17 18:26:57 */
|
|
2
|
+
import { resolveCSSVars as T } from "../modules/CSSVar.js";
|
|
3
|
+
import { inlineAllStyles as p } from "../modules/styles.js";
|
|
4
|
+
import { rasterizeIframe as M, freezeImgSrcset as v, nextShadowScopeId as $, extractShadowCSS as L, rewriteShadowCSS as R, collectCustomPropsFromCSS as k, buildSeedCustomPropsRule as I, injectScopedStyle as H, idleCallback as x, markSlottedSubtree as C } from "../utils/clone.helpers.js";
|
|
5
|
+
import { NO_CAPTURE_TAGS as D } from "../utils/css.js";
|
|
6
|
+
async function S(t, s, c) {
|
|
164
7
|
if (!t) throw new Error("Invalid node");
|
|
165
|
-
const
|
|
166
|
-
let
|
|
8
|
+
const b = /* @__PURE__ */ new Set();
|
|
9
|
+
let w = null, y = null;
|
|
167
10
|
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
168
|
-
const
|
|
169
|
-
if (t.id === "snapdom-sandbox" || t.hasAttribute("data-snapdom-sandbox") ||
|
|
11
|
+
const e = (t.localName || t.tagName || "").toLowerCase();
|
|
12
|
+
if (t.id === "snapdom-sandbox" || t.hasAttribute("data-snapdom-sandbox") || D.has(e))
|
|
170
13
|
return null;
|
|
171
14
|
}
|
|
172
15
|
if (t.nodeType === Node.TEXT_NODE || t.nodeType !== Node.ELEMENT_NODE)
|
|
173
16
|
return t.cloneNode(!0);
|
|
174
17
|
if (t.getAttribute("data-capture") === "exclude") {
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
-
} else if (
|
|
18
|
+
if (c.excludeMode === "hide") {
|
|
19
|
+
const e = document.createElement("div"), a = t.getBoundingClientRect();
|
|
20
|
+
return e.style.cssText = `display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`, e;
|
|
21
|
+
} else if (c.excludeMode === "remove")
|
|
179
22
|
return null;
|
|
180
23
|
}
|
|
181
|
-
if (
|
|
182
|
-
for (const
|
|
24
|
+
if (c.exclude && Array.isArray(c.exclude))
|
|
25
|
+
for (const e of c.exclude)
|
|
183
26
|
try {
|
|
184
|
-
if (t.matches?.(
|
|
185
|
-
if (
|
|
186
|
-
const a = document.createElement("div"),
|
|
187
|
-
return a.style.cssText = `display:inline-block;width:${
|
|
188
|
-
} else if (
|
|
27
|
+
if (t.matches?.(e)) {
|
|
28
|
+
if (c.excludeMode === "hide") {
|
|
29
|
+
const a = document.createElement("div"), i = t.getBoundingClientRect();
|
|
30
|
+
return a.style.cssText = `display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`, a;
|
|
31
|
+
} else if (c.excludeMode === "remove")
|
|
189
32
|
return null;
|
|
190
33
|
}
|
|
191
34
|
} catch (a) {
|
|
192
|
-
console.warn(`Invalid selector in exclude option: ${
|
|
35
|
+
console.warn(`Invalid selector in exclude option: ${e}`, a);
|
|
193
36
|
}
|
|
194
|
-
if (typeof
|
|
37
|
+
if (typeof c.filter == "function")
|
|
195
38
|
try {
|
|
196
|
-
if (!
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
return
|
|
200
|
-
} else if (
|
|
39
|
+
if (!c.filter(t)) {
|
|
40
|
+
if (c.filterMode === "hide") {
|
|
41
|
+
const e = document.createElement("div"), a = t.getBoundingClientRect();
|
|
42
|
+
return e.style.cssText = `display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`, e;
|
|
43
|
+
} else if (c.filterMode === "remove")
|
|
201
44
|
return null;
|
|
202
45
|
}
|
|
203
|
-
} catch (
|
|
204
|
-
console.warn("Error in filter function:",
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.warn("Error in filter function:", e);
|
|
205
48
|
}
|
|
206
49
|
if (t.tagName === "IFRAME") {
|
|
207
|
-
let
|
|
50
|
+
let e = !1;
|
|
208
51
|
try {
|
|
209
|
-
|
|
52
|
+
e = !!(t.contentDocument || t.contentWindow?.document);
|
|
210
53
|
} catch {
|
|
211
|
-
|
|
54
|
+
e = !1;
|
|
212
55
|
}
|
|
213
|
-
if (
|
|
56
|
+
if (e)
|
|
214
57
|
try {
|
|
215
|
-
return await
|
|
58
|
+
return await M(t, s, c);
|
|
216
59
|
} catch (a) {
|
|
217
60
|
console.warn("[SnapDOM] iframe rasterization failed, fallback:", a);
|
|
218
61
|
}
|
|
219
|
-
if (
|
|
62
|
+
if (c.placeholders) {
|
|
220
63
|
const a = document.createElement("div");
|
|
221
|
-
return a.style.cssText = `width:${t.offsetWidth}px;height:${t.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,
|
|
64
|
+
return a.style.cssText = `width:${t.offsetWidth}px;height:${t.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`, p(t, a, s, c), a;
|
|
222
65
|
} else {
|
|
223
|
-
const a = t.getBoundingClientRect(),
|
|
224
|
-
return
|
|
66
|
+
const a = t.getBoundingClientRect(), i = document.createElement("div");
|
|
67
|
+
return i.style.cssText = `display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`, p(t, i, s, c), i;
|
|
225
68
|
}
|
|
226
69
|
}
|
|
227
70
|
if (t.getAttribute("data-capture") === "placeholder") {
|
|
228
|
-
const
|
|
229
|
-
|
|
71
|
+
const e = t.cloneNode(!1);
|
|
72
|
+
s.nodeMap.set(e, t), p(t, e, s, c);
|
|
230
73
|
const a = document.createElement("div");
|
|
231
|
-
return a.textContent = t.getAttribute("data-placeholder-text") || "", a.style.cssText = "color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",
|
|
74
|
+
return a.textContent = t.getAttribute("data-placeholder-text") || "", a.style.cssText = "color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;", e.appendChild(a), e;
|
|
232
75
|
}
|
|
233
76
|
if (t.tagName === "CANVAS") {
|
|
234
|
-
let
|
|
77
|
+
let e = "";
|
|
235
78
|
try {
|
|
236
|
-
const
|
|
79
|
+
const i = t.getContext("2d", { willReadFrequently: !0 });
|
|
237
80
|
try {
|
|
238
|
-
|
|
81
|
+
i && i.getImageData(0, 0, 1, 1);
|
|
239
82
|
} catch {
|
|
240
83
|
}
|
|
241
|
-
if (await new Promise((
|
|
84
|
+
if (await new Promise((l) => requestAnimationFrame(l)), e = t.toDataURL("image/png"), !e || e === "data:,") {
|
|
242
85
|
try {
|
|
243
|
-
|
|
86
|
+
i && i.getImageData(0, 0, 1, 1);
|
|
244
87
|
} catch {
|
|
245
88
|
}
|
|
246
|
-
if (await new Promise((
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
89
|
+
if (await new Promise((l) => requestAnimationFrame(l)), e = t.toDataURL("image/png"), !e || e === "data:,") {
|
|
90
|
+
const l = document.createElement("canvas");
|
|
91
|
+
l.width = t.width, l.height = t.height;
|
|
92
|
+
const n = l.getContext("2d");
|
|
93
|
+
n && (n.drawImage(t, 0, 0), e = l.toDataURL("image/png"));
|
|
251
94
|
}
|
|
252
95
|
}
|
|
253
96
|
} catch {
|
|
@@ -257,108 +100,116 @@ async function A(t, r, n) {
|
|
|
257
100
|
a.decoding = "sync", a.loading = "eager";
|
|
258
101
|
} catch {
|
|
259
102
|
}
|
|
260
|
-
|
|
103
|
+
e && (a.src = e), a.width = t.width, a.height = t.height;
|
|
261
104
|
try {
|
|
262
|
-
const
|
|
263
|
-
|
|
105
|
+
const i = getComputedStyle(t);
|
|
106
|
+
i.width && (a.style.width = i.width), i.height && (a.style.height = i.height);
|
|
264
107
|
} catch {
|
|
265
108
|
}
|
|
266
|
-
return
|
|
109
|
+
return s.nodeMap.set(a, t), p(t, a, s, c), a;
|
|
267
110
|
}
|
|
268
|
-
let
|
|
111
|
+
let r;
|
|
269
112
|
try {
|
|
270
|
-
if (
|
|
271
|
-
|
|
113
|
+
if (r = t.cloneNode(!1), T(t, r), s.nodeMap.set(r, t), t.tagName === "IMG") {
|
|
114
|
+
v(t, r);
|
|
272
115
|
try {
|
|
273
|
-
const
|
|
274
|
-
let a = Math.round(
|
|
275
|
-
if (!a || !
|
|
276
|
-
const
|
|
277
|
-
a = Math.round(a ||
|
|
116
|
+
const e = t.getBoundingClientRect();
|
|
117
|
+
let a = Math.round(e.width || 0), i = Math.round(e.height || 0);
|
|
118
|
+
if (!a || !i) {
|
|
119
|
+
const l = window.getComputedStyle(t), n = parseFloat(l.width) || 0, h = parseFloat(l.height) || 0, u = parseInt(t.getAttribute("width") || "", 10) || 0, o = parseInt(t.getAttribute("height") || "", 10) || 0, g = t.width || t.naturalWidth || 0, d = t.height || t.naturalHeight || 0;
|
|
120
|
+
a = Math.round(a || n || u || g || 0), i = Math.round(i || h || o || d || 0);
|
|
278
121
|
}
|
|
279
|
-
a && (
|
|
122
|
+
a && (r.dataset.snapdomWidth = String(a)), i && (r.dataset.snapdomHeight = String(i));
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const e = t.getAttribute("style") || "", a = window.getComputedStyle(t), i = (o) => {
|
|
127
|
+
const g = e.match(new RegExp(`${o}\\s*:\\s*([^;]+)`, "i")), d = g ? g[1].trim() : a.getPropertyValue(o);
|
|
128
|
+
return /%|auto/i.test(String(d || ""));
|
|
129
|
+
}, l = parseInt(r.dataset.snapdomWidth || "0", 10), n = parseInt(r.dataset.snapdomHeight || "0", 10), h = i("width") || !l, u = i("height") || !n;
|
|
130
|
+
h && l && (r.style.width = `${l}px`), u && n && (r.style.height = `${n}px`), l && (r.style.minWidth = `${l}px`), n && (r.style.minHeight = `${n}px`);
|
|
280
131
|
} catch {
|
|
281
132
|
}
|
|
282
133
|
}
|
|
283
|
-
} catch (
|
|
284
|
-
throw console.error("[Snapdom] Failed to clone node:", t,
|
|
134
|
+
} catch (e) {
|
|
135
|
+
throw console.error("[Snapdom] Failed to clone node:", t, e), e;
|
|
285
136
|
}
|
|
286
137
|
if (t instanceof HTMLTextAreaElement) {
|
|
287
|
-
const
|
|
288
|
-
|
|
138
|
+
const e = t.getBoundingClientRect();
|
|
139
|
+
r.style.width = `${e.width}px`, r.style.height = `${e.height}px`;
|
|
289
140
|
}
|
|
290
|
-
if (t instanceof HTMLInputElement && (
|
|
291
|
-
let
|
|
141
|
+
if (t instanceof HTMLInputElement && (r.value = t.value, r.setAttribute("value", t.value), t.checked !== void 0 && (r.checked = t.checked, t.checked && r.setAttribute("checked", ""), t.indeterminate && (r.indeterminate = t.indeterminate))), t instanceof HTMLSelectElement && (w = t.value), t instanceof HTMLTextAreaElement && (y = t.value), p(t, r, s, c), t.shadowRoot) {
|
|
142
|
+
let o = function(d, f) {
|
|
292
143
|
if (d.nodeType === Node.ELEMENT_NODE && d.tagName === "STYLE")
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
144
|
+
return f(null);
|
|
145
|
+
S(d, s, c).then((m) => {
|
|
146
|
+
f(m || null);
|
|
296
147
|
}).catch(() => {
|
|
297
|
-
|
|
148
|
+
f(null);
|
|
298
149
|
});
|
|
299
150
|
};
|
|
300
151
|
try {
|
|
301
152
|
const d = t.shadowRoot.querySelectorAll("slot");
|
|
302
|
-
for (const
|
|
303
|
-
let
|
|
153
|
+
for (const f of d) {
|
|
154
|
+
let m = [];
|
|
304
155
|
try {
|
|
305
|
-
|
|
156
|
+
m = f.assignedNodes?.({ flatten: !0 }) || f.assignedNodes?.() || [];
|
|
306
157
|
} catch {
|
|
307
|
-
|
|
158
|
+
m = f.assignedNodes?.() || [];
|
|
308
159
|
}
|
|
309
|
-
for (const
|
|
160
|
+
for (const N of m) b.add(N);
|
|
310
161
|
}
|
|
311
162
|
} catch {
|
|
312
163
|
}
|
|
313
|
-
const
|
|
164
|
+
const e = $(s), a = `[data-sd="${e}"]`;
|
|
314
165
|
try {
|
|
315
|
-
|
|
166
|
+
r.setAttribute("data-sd", e);
|
|
316
167
|
} catch {
|
|
317
168
|
}
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
const
|
|
169
|
+
const i = L(t.shadowRoot), l = R(i, a), n = k(i), h = I(t, n, a);
|
|
170
|
+
H(r, h + l, e);
|
|
171
|
+
const u = document.createDocumentFragment(), g = await x(
|
|
321
172
|
Array.from(t.shadowRoot.childNodes),
|
|
322
|
-
|
|
323
|
-
|
|
173
|
+
o,
|
|
174
|
+
c.fast
|
|
324
175
|
);
|
|
325
|
-
|
|
176
|
+
u.append(...g.filter((d) => !!d)), r.appendChild(u);
|
|
326
177
|
}
|
|
327
178
|
if (t.tagName === "SLOT") {
|
|
328
|
-
let
|
|
329
|
-
|
|
330
|
-
|
|
179
|
+
let l = function(h, u) {
|
|
180
|
+
S(h, s, c).then((o) => {
|
|
181
|
+
o && C(o), u(o || null);
|
|
331
182
|
}).catch(() => {
|
|
332
|
-
|
|
183
|
+
u(null);
|
|
333
184
|
});
|
|
334
185
|
};
|
|
335
|
-
const
|
|
186
|
+
const e = t.assignedNodes?.({ flatten: !0 }) || [], a = e.length > 0 ? e : Array.from(t.childNodes), i = document.createDocumentFragment(), n = await x(
|
|
336
187
|
Array.from(a),
|
|
337
|
-
|
|
338
|
-
|
|
188
|
+
l,
|
|
189
|
+
c.fast
|
|
339
190
|
);
|
|
340
|
-
return
|
|
191
|
+
return i.append(...n.filter((h) => !!h)), i;
|
|
341
192
|
}
|
|
342
|
-
function
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
a(
|
|
193
|
+
function E(e, a) {
|
|
194
|
+
if (b.has(e)) return a(null);
|
|
195
|
+
S(e, s, c).then((i) => {
|
|
196
|
+
a(i || null);
|
|
346
197
|
}).catch(() => {
|
|
347
198
|
a(null);
|
|
348
199
|
});
|
|
349
200
|
}
|
|
350
|
-
const
|
|
201
|
+
const A = await x(
|
|
351
202
|
Array.from(t.childNodes),
|
|
352
|
-
|
|
353
|
-
|
|
203
|
+
E,
|
|
204
|
+
c.fast
|
|
354
205
|
);
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
for (const
|
|
358
|
-
|
|
206
|
+
if (r.append(...A.filter((e) => !!e)), w !== null && r instanceof HTMLSelectElement) {
|
|
207
|
+
r.value = w;
|
|
208
|
+
for (const e of r.options)
|
|
209
|
+
e.value === w ? e.setAttribute("selected", "") : e.removeAttribute("selected");
|
|
359
210
|
}
|
|
360
|
-
return
|
|
211
|
+
return y !== null && r instanceof HTMLTextAreaElement && (r.textContent = y), r;
|
|
361
212
|
}
|
|
362
213
|
export {
|
|
363
|
-
|
|
214
|
+
S as deepClone
|
|
364
215
|
};
|