@percy/sdk-utils
Advanced tools
+58
-0
@@ -502,2 +502,50 @@ (function() { | ||
| // Canonical list of iframe `src` URL prefixes that out-of-process SDK frame | ||
| // walks (Capybara, Nightwatch, Playwright, Puppeteer, Selenium, ...) must NOT | ||
| // switch into / serialize: browser-internal pages, non-HTTP schemes, and | ||
| // pseudo-protocols that either can't be navigated cross-process or are unsafe | ||
| // to recurse into. SINGLE SOURCE OF TRUTH — every SDK previously hand-copied | ||
| // this list (it drifted into 4 divergent versions), so they now consume it | ||
| // from here instead. `startsWith`, case-insensitive. | ||
| const UNSUPPORTED_IFRAME_SRCS = ['about:', 'chrome:', 'chrome-extension:', 'devtools:', 'edge:', 'opera:', 'view-source:', 'data:', 'javascript:', 'blob:', 'vbscript:', 'file:', 'ws:', 'wss:', 'ftp:']; | ||
| // True when an iframe `src` should be skipped by an SDK frame walk. A missing | ||
| // / empty src is treated as unsupported (nothing to navigate to). | ||
| function isUnsupportedIframeSrc(src) { | ||
| if (!src) return true; | ||
| const s = String(src).toLowerCase(); | ||
| return UNSUPPORTED_IFRAME_SRCS.some(prefix => s.startsWith(prefix)); | ||
| } | ||
| // Normalize a raw ignore-selectors value (array | string | unset) into a | ||
| // clean string[]. PercyDOM does `selectors?.length && selectors.some(...)`, | ||
| // which throws when handed a bare string (has .length, no .some), so SDKs | ||
| // must normalize before forwarding — this is the shared primitive. | ||
| function normalizeIgnoreSelectors(value) { | ||
| if (!value) return []; | ||
| if (Array.isArray(value)) return value.filter(s => typeof s === 'string' && s.length); | ||
| if (typeof value === 'string') return [value]; | ||
| return []; | ||
| } | ||
| // Resolve the effective maxIframeDepth for a snapshot: per-snapshot option | ||
| // wins over the global `percy.config.snapshot.maxIframeDepth`, then the value | ||
| // is clamped to [1, HARD_MAX_IFRAME_DEPTH] (invalid/<1 -> default). | ||
| function resolveMaxFrameDepth(options = {}) { | ||
| var _percy$config; | ||
| let raw = options.maxIframeDepth; | ||
| if (raw == null) raw = info === null || info === void 0 || (_percy$config = info.config) === null || _percy$config === void 0 || (_percy$config = _percy$config.snapshot) === null || _percy$config === void 0 ? void 0 : _percy$config.maxIframeDepth; | ||
| return clampIframeDepth(raw); | ||
| } | ||
| // Resolve the effective ignoreIframeSelectors for a snapshot: per-snapshot | ||
| // option wins; when absent, fall back to the global | ||
| // `percy.config.snapshot.ignoreIframeSelectors`. Always returns a string[]. | ||
| function resolveIgnoreSelectors(options = {}) { | ||
| var _percy$config2; | ||
| const perSnapshot = normalizeIgnoreSelectors(options.ignoreIframeSelectors ?? options.ignoreSelectors); | ||
| if (perSnapshot.length) return perSnapshot; | ||
| return normalizeIgnoreSelectors(info === null || info === void 0 || (_percy$config2 = info.config) === null || _percy$config2 === void 0 || (_percy$config2 = _percy$config2.snapshot) === null || _percy$config2 === void 0 ? void 0 : _percy$config2.ignoreIframeSelectors); | ||
| } | ||
| var index = /*#__PURE__*/Object.freeze({ | ||
@@ -521,2 +569,7 @@ __proto__: null, | ||
| clampIframeDepth: clampIframeDepth, | ||
| UNSUPPORTED_IFRAME_SRCS: UNSUPPORTED_IFRAME_SRCS, | ||
| isUnsupportedIframeSrc: isUnsupportedIframeSrc, | ||
| normalizeIgnoreSelectors: normalizeIgnoreSelectors, | ||
| resolveMaxFrameDepth: resolveMaxFrameDepth, | ||
| resolveIgnoreSelectors: resolveIgnoreSelectors, | ||
| waitForReadyScript: waitForReadyScript, | ||
@@ -531,2 +584,3 @@ getReadinessConfig: getReadinessConfig, | ||
| exports.HARD_MAX_IFRAME_DEPTH = HARD_MAX_IFRAME_DEPTH; | ||
| exports.UNSUPPORTED_IFRAME_SRCS = UNSUPPORTED_IFRAME_SRCS; | ||
| exports.captureAutomateScreenshot = captureAutomateScreenshot; | ||
@@ -541,4 +595,6 @@ exports.clampIframeDepth = clampIframeDepth; | ||
| exports.isReadinessDisabled = isReadinessDisabled; | ||
| exports.isUnsupportedIframeSrc = isUnsupportedIframeSrc; | ||
| exports.logger = logger; | ||
| exports.mergeSnapshotOptions = mergeSnapshotOptions; | ||
| exports.normalizeIgnoreSelectors = normalizeIgnoreSelectors; | ||
| exports.percy = info; | ||
@@ -549,2 +605,4 @@ exports.postBuildEvents = postBuildEvents; | ||
| exports.request = request; | ||
| exports.resolveIgnoreSelectors = resolveIgnoreSelectors; | ||
| exports.resolveMaxFrameDepth = resolveMaxFrameDepth; | ||
| exports.runReadinessGate = runReadinessGate; | ||
@@ -551,0 +609,0 @@ exports.waitForPercyIdle = waitForPercyIdle; |
+53
-1
@@ -6,3 +6,3 @@ "use strict"; | ||
| }); | ||
| exports.HARD_MAX_IFRAME_DEPTH = exports.DEFAULT_MAX_IFRAME_DEPTH = void 0; | ||
| exports.UNSUPPORTED_IFRAME_SRCS = exports.HARD_MAX_IFRAME_DEPTH = exports.DEFAULT_MAX_IFRAME_DEPTH = void 0; | ||
| Object.defineProperty(exports, "captureAutomateScreenshot", { | ||
@@ -52,2 +52,3 @@ enumerable: true, | ||
| }); | ||
| exports.isUnsupportedIframeSrc = isUnsupportedIframeSrc; | ||
| Object.defineProperty(exports, "logger", { | ||
@@ -65,2 +66,3 @@ enumerable: true, | ||
| }); | ||
| exports.normalizeIgnoreSelectors = normalizeIgnoreSelectors; | ||
| Object.defineProperty(exports, "percy", { | ||
@@ -96,2 +98,4 @@ enumerable: true, | ||
| }); | ||
| exports.resolveIgnoreSelectors = resolveIgnoreSelectors; | ||
| exports.resolveMaxFrameDepth = resolveMaxFrameDepth; | ||
| Object.defineProperty(exports, "runReadinessGate", { | ||
@@ -150,2 +154,50 @@ enumerable: true, | ||
| // Canonical list of iframe `src` URL prefixes that out-of-process SDK frame | ||
| // walks (Capybara, Nightwatch, Playwright, Puppeteer, Selenium, ...) must NOT | ||
| // switch into / serialize: browser-internal pages, non-HTTP schemes, and | ||
| // pseudo-protocols that either can't be navigated cross-process or are unsafe | ||
| // to recurse into. SINGLE SOURCE OF TRUTH — every SDK previously hand-copied | ||
| // this list (it drifted into 4 divergent versions), so they now consume it | ||
| // from here instead. `startsWith`, case-insensitive. | ||
| const UNSUPPORTED_IFRAME_SRCS = exports.UNSUPPORTED_IFRAME_SRCS = ['about:', 'chrome:', 'chrome-extension:', 'devtools:', 'edge:', 'opera:', 'view-source:', 'data:', 'javascript:', 'blob:', 'vbscript:', 'file:', 'ws:', 'wss:', 'ftp:']; | ||
| // True when an iframe `src` should be skipped by an SDK frame walk. A missing | ||
| // / empty src is treated as unsupported (nothing to navigate to). | ||
| function isUnsupportedIframeSrc(src) { | ||
| if (!src) return true; | ||
| const s = String(src).toLowerCase(); | ||
| return UNSUPPORTED_IFRAME_SRCS.some(prefix => s.startsWith(prefix)); | ||
| } | ||
| // Normalize a raw ignore-selectors value (array | string | unset) into a | ||
| // clean string[]. PercyDOM does `selectors?.length && selectors.some(...)`, | ||
| // which throws when handed a bare string (has .length, no .some), so SDKs | ||
| // must normalize before forwarding — this is the shared primitive. | ||
| function normalizeIgnoreSelectors(value) { | ||
| if (!value) return []; | ||
| if (Array.isArray(value)) return value.filter(s => typeof s === 'string' && s.length); | ||
| if (typeof value === 'string') return [value]; | ||
| return []; | ||
| } | ||
| // Resolve the effective maxIframeDepth for a snapshot: per-snapshot option | ||
| // wins over the global `percy.config.snapshot.maxIframeDepth`, then the value | ||
| // is clamped to [1, HARD_MAX_IFRAME_DEPTH] (invalid/<1 -> default). | ||
| function resolveMaxFrameDepth(options = {}) { | ||
| var _percy$config; | ||
| let raw = options.maxIframeDepth; | ||
| if (raw == null) raw = _percyInfo.default === null || _percyInfo.default === void 0 || (_percy$config = _percyInfo.default.config) === null || _percy$config === void 0 || (_percy$config = _percy$config.snapshot) === null || _percy$config === void 0 ? void 0 : _percy$config.maxIframeDepth; | ||
| return clampIframeDepth(raw); | ||
| } | ||
| // Resolve the effective ignoreIframeSelectors for a snapshot: per-snapshot | ||
| // option wins; when absent, fall back to the global | ||
| // `percy.config.snapshot.ignoreIframeSelectors`. Always returns a string[]. | ||
| function resolveIgnoreSelectors(options = {}) { | ||
| var _percy$config2; | ||
| const perSnapshot = normalizeIgnoreSelectors(options.ignoreIframeSelectors ?? options.ignoreSelectors); | ||
| if (perSnapshot.length) return perSnapshot; | ||
| return normalizeIgnoreSelectors(_percyInfo.default === null || _percyInfo.default === void 0 || (_percy$config2 = _percyInfo.default.config) === null || _percy$config2 === void 0 || (_percy$config2 = _percy$config2.snapshot) === null || _percy$config2 === void 0 ? void 0 : _percy$config2.ignoreIframeSelectors); | ||
| } | ||
| // export the namespace by default |
+2
-2
| { | ||
| "name": "@percy/sdk-utils", | ||
| "version": "1.32.3-beta.0", | ||
| "version": "1.32.3-beta.1", | ||
| "license": "MIT", | ||
@@ -57,3 +57,3 @@ "repository": { | ||
| }, | ||
| "gitHead": "e8af175695b4afdb78cdd48b67037710f5c8b1c9" | ||
| "gitHead": "92723d8feb00ce604c67dcd1e28c93b498c6996f" | ||
| } |
82926
9.06%1769
6.06%