@percy/sdk-utils 1.32.3-beta.0 → 1.32.3-beta.1
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/dist/bundle.js +58 -0
- package/dist/index.js +53 -1
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -499,6 +499,54 @@
|
|
|
499
499
|
return Math.min(Math.floor(n), HARD_MAX_IFRAME_DEPTH);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
// Canonical list of iframe `src` URL prefixes that out-of-process SDK frame
|
|
503
|
+
// walks (Capybara, Nightwatch, Playwright, Puppeteer, Selenium, ...) must NOT
|
|
504
|
+
// switch into / serialize: browser-internal pages, non-HTTP schemes, and
|
|
505
|
+
// pseudo-protocols that either can't be navigated cross-process or are unsafe
|
|
506
|
+
// to recurse into. SINGLE SOURCE OF TRUTH — every SDK previously hand-copied
|
|
507
|
+
// this list (it drifted into 4 divergent versions), so they now consume it
|
|
508
|
+
// from here instead. `startsWith`, case-insensitive.
|
|
509
|
+
const UNSUPPORTED_IFRAME_SRCS = ['about:', 'chrome:', 'chrome-extension:', 'devtools:', 'edge:', 'opera:', 'view-source:', 'data:', 'javascript:', 'blob:', 'vbscript:', 'file:', 'ws:', 'wss:', 'ftp:'];
|
|
510
|
+
|
|
511
|
+
// True when an iframe `src` should be skipped by an SDK frame walk. A missing
|
|
512
|
+
// / empty src is treated as unsupported (nothing to navigate to).
|
|
513
|
+
function isUnsupportedIframeSrc(src) {
|
|
514
|
+
if (!src) return true;
|
|
515
|
+
const s = String(src).toLowerCase();
|
|
516
|
+
return UNSUPPORTED_IFRAME_SRCS.some(prefix => s.startsWith(prefix));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Normalize a raw ignore-selectors value (array | string | unset) into a
|
|
520
|
+
// clean string[]. PercyDOM does `selectors?.length && selectors.some(...)`,
|
|
521
|
+
// which throws when handed a bare string (has .length, no .some), so SDKs
|
|
522
|
+
// must normalize before forwarding — this is the shared primitive.
|
|
523
|
+
function normalizeIgnoreSelectors(value) {
|
|
524
|
+
if (!value) return [];
|
|
525
|
+
if (Array.isArray(value)) return value.filter(s => typeof s === 'string' && s.length);
|
|
526
|
+
if (typeof value === 'string') return [value];
|
|
527
|
+
return [];
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Resolve the effective maxIframeDepth for a snapshot: per-snapshot option
|
|
531
|
+
// wins over the global `percy.config.snapshot.maxIframeDepth`, then the value
|
|
532
|
+
// is clamped to [1, HARD_MAX_IFRAME_DEPTH] (invalid/<1 -> default).
|
|
533
|
+
function resolveMaxFrameDepth(options = {}) {
|
|
534
|
+
var _percy$config;
|
|
535
|
+
let raw = options.maxIframeDepth;
|
|
536
|
+
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;
|
|
537
|
+
return clampIframeDepth(raw);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Resolve the effective ignoreIframeSelectors for a snapshot: per-snapshot
|
|
541
|
+
// option wins; when absent, fall back to the global
|
|
542
|
+
// `percy.config.snapshot.ignoreIframeSelectors`. Always returns a string[].
|
|
543
|
+
function resolveIgnoreSelectors(options = {}) {
|
|
544
|
+
var _percy$config2;
|
|
545
|
+
const perSnapshot = normalizeIgnoreSelectors(options.ignoreIframeSelectors ?? options.ignoreSelectors);
|
|
546
|
+
if (perSnapshot.length) return perSnapshot;
|
|
547
|
+
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);
|
|
548
|
+
}
|
|
549
|
+
|
|
502
550
|
var index = /*#__PURE__*/Object.freeze({
|
|
503
551
|
__proto__: null,
|
|
504
552
|
logger: logger,
|
|
@@ -517,6 +565,11 @@
|
|
|
517
565
|
DEFAULT_MAX_IFRAME_DEPTH: DEFAULT_MAX_IFRAME_DEPTH,
|
|
518
566
|
HARD_MAX_IFRAME_DEPTH: HARD_MAX_IFRAME_DEPTH,
|
|
519
567
|
clampIframeDepth: clampIframeDepth,
|
|
568
|
+
UNSUPPORTED_IFRAME_SRCS: UNSUPPORTED_IFRAME_SRCS,
|
|
569
|
+
isUnsupportedIframeSrc: isUnsupportedIframeSrc,
|
|
570
|
+
normalizeIgnoreSelectors: normalizeIgnoreSelectors,
|
|
571
|
+
resolveMaxFrameDepth: resolveMaxFrameDepth,
|
|
572
|
+
resolveIgnoreSelectors: resolveIgnoreSelectors,
|
|
520
573
|
waitForReadyScript: waitForReadyScript,
|
|
521
574
|
getReadinessConfig: getReadinessConfig,
|
|
522
575
|
isReadinessDisabled: isReadinessDisabled,
|
|
@@ -526,6 +579,7 @@
|
|
|
526
579
|
|
|
527
580
|
exports.DEFAULT_MAX_IFRAME_DEPTH = DEFAULT_MAX_IFRAME_DEPTH;
|
|
528
581
|
exports.HARD_MAX_IFRAME_DEPTH = HARD_MAX_IFRAME_DEPTH;
|
|
582
|
+
exports.UNSUPPORTED_IFRAME_SRCS = UNSUPPORTED_IFRAME_SRCS;
|
|
529
583
|
exports.captureAutomateScreenshot = captureAutomateScreenshot;
|
|
530
584
|
exports.clampIframeDepth = clampIframeDepth;
|
|
531
585
|
exports["default"] = index;
|
|
@@ -535,13 +589,17 @@
|
|
|
535
589
|
exports.getResponsiveWidths = getResponsiveWidths;
|
|
536
590
|
exports.isPercyEnabled = isPercyEnabled;
|
|
537
591
|
exports.isReadinessDisabled = isReadinessDisabled;
|
|
592
|
+
exports.isUnsupportedIframeSrc = isUnsupportedIframeSrc;
|
|
538
593
|
exports.logger = logger;
|
|
539
594
|
exports.mergeSnapshotOptions = mergeSnapshotOptions;
|
|
595
|
+
exports.normalizeIgnoreSelectors = normalizeIgnoreSelectors;
|
|
540
596
|
exports.percy = info;
|
|
541
597
|
exports.postBuildEvents = postBuildEvents;
|
|
542
598
|
exports.postComparison = postComparison;
|
|
543
599
|
exports.postSnapshot = postSnapshot;
|
|
544
600
|
exports.request = request;
|
|
601
|
+
exports.resolveIgnoreSelectors = resolveIgnoreSelectors;
|
|
602
|
+
exports.resolveMaxFrameDepth = resolveMaxFrameDepth;
|
|
545
603
|
exports.runReadinessGate = runReadinessGate;
|
|
546
604
|
exports.waitForPercyIdle = waitForPercyIdle;
|
|
547
605
|
exports.waitForReadyScript = waitForReadyScript;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.HARD_MAX_IFRAME_DEPTH = exports.DEFAULT_MAX_IFRAME_DEPTH = void 0;
|
|
6
|
+
exports.UNSUPPORTED_IFRAME_SRCS = exports.HARD_MAX_IFRAME_DEPTH = exports.DEFAULT_MAX_IFRAME_DEPTH = void 0;
|
|
7
7
|
Object.defineProperty(exports, "captureAutomateScreenshot", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
@@ -48,6 +48,7 @@ Object.defineProperty(exports, "isReadinessDisabled", {
|
|
|
48
48
|
return _serializeDom.isReadinessDisabled;
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
+
exports.isUnsupportedIframeSrc = isUnsupportedIframeSrc;
|
|
51
52
|
Object.defineProperty(exports, "logger", {
|
|
52
53
|
enumerable: true,
|
|
53
54
|
get: function () {
|
|
@@ -60,6 +61,7 @@ Object.defineProperty(exports, "mergeSnapshotOptions", {
|
|
|
60
61
|
return _mergeSnapshotOptions.default;
|
|
61
62
|
}
|
|
62
63
|
});
|
|
64
|
+
exports.normalizeIgnoreSelectors = normalizeIgnoreSelectors;
|
|
63
65
|
Object.defineProperty(exports, "percy", {
|
|
64
66
|
enumerable: true,
|
|
65
67
|
get: function () {
|
|
@@ -90,6 +92,8 @@ Object.defineProperty(exports, "request", {
|
|
|
90
92
|
return _request.default;
|
|
91
93
|
}
|
|
92
94
|
});
|
|
95
|
+
exports.resolveIgnoreSelectors = resolveIgnoreSelectors;
|
|
96
|
+
exports.resolveMaxFrameDepth = resolveMaxFrameDepth;
|
|
93
97
|
Object.defineProperty(exports, "runReadinessGate", {
|
|
94
98
|
enumerable: true,
|
|
95
99
|
get: function () {
|
|
@@ -143,4 +147,52 @@ function clampIframeDepth(raw) {
|
|
|
143
147
|
return Math.min(Math.floor(n), HARD_MAX_IFRAME_DEPTH);
|
|
144
148
|
}
|
|
145
149
|
|
|
150
|
+
// Canonical list of iframe `src` URL prefixes that out-of-process SDK frame
|
|
151
|
+
// walks (Capybara, Nightwatch, Playwright, Puppeteer, Selenium, ...) must NOT
|
|
152
|
+
// switch into / serialize: browser-internal pages, non-HTTP schemes, and
|
|
153
|
+
// pseudo-protocols that either can't be navigated cross-process or are unsafe
|
|
154
|
+
// to recurse into. SINGLE SOURCE OF TRUTH — every SDK previously hand-copied
|
|
155
|
+
// this list (it drifted into 4 divergent versions), so they now consume it
|
|
156
|
+
// from here instead. `startsWith`, case-insensitive.
|
|
157
|
+
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:'];
|
|
158
|
+
|
|
159
|
+
// True when an iframe `src` should be skipped by an SDK frame walk. A missing
|
|
160
|
+
// / empty src is treated as unsupported (nothing to navigate to).
|
|
161
|
+
function isUnsupportedIframeSrc(src) {
|
|
162
|
+
if (!src) return true;
|
|
163
|
+
const s = String(src).toLowerCase();
|
|
164
|
+
return UNSUPPORTED_IFRAME_SRCS.some(prefix => s.startsWith(prefix));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Normalize a raw ignore-selectors value (array | string | unset) into a
|
|
168
|
+
// clean string[]. PercyDOM does `selectors?.length && selectors.some(...)`,
|
|
169
|
+
// which throws when handed a bare string (has .length, no .some), so SDKs
|
|
170
|
+
// must normalize before forwarding — this is the shared primitive.
|
|
171
|
+
function normalizeIgnoreSelectors(value) {
|
|
172
|
+
if (!value) return [];
|
|
173
|
+
if (Array.isArray(value)) return value.filter(s => typeof s === 'string' && s.length);
|
|
174
|
+
if (typeof value === 'string') return [value];
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Resolve the effective maxIframeDepth for a snapshot: per-snapshot option
|
|
179
|
+
// wins over the global `percy.config.snapshot.maxIframeDepth`, then the value
|
|
180
|
+
// is clamped to [1, HARD_MAX_IFRAME_DEPTH] (invalid/<1 -> default).
|
|
181
|
+
function resolveMaxFrameDepth(options = {}) {
|
|
182
|
+
var _percy$config;
|
|
183
|
+
let raw = options.maxIframeDepth;
|
|
184
|
+
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;
|
|
185
|
+
return clampIframeDepth(raw);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Resolve the effective ignoreIframeSelectors for a snapshot: per-snapshot
|
|
189
|
+
// option wins; when absent, fall back to the global
|
|
190
|
+
// `percy.config.snapshot.ignoreIframeSelectors`. Always returns a string[].
|
|
191
|
+
function resolveIgnoreSelectors(options = {}) {
|
|
192
|
+
var _percy$config2;
|
|
193
|
+
const perSnapshot = normalizeIgnoreSelectors(options.ignoreIframeSelectors ?? options.ignoreSelectors);
|
|
194
|
+
if (perSnapshot.length) return perSnapshot;
|
|
195
|
+
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);
|
|
196
|
+
}
|
|
197
|
+
|
|
146
198
|
// export the namespace by default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/sdk-utils",
|
|
3
|
-
"version": "1.32.3-beta.
|
|
3
|
+
"version": "1.32.3-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"pac-proxy-agent": "^7.0.2"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "92723d8feb00ce604c67dcd1e28c93b498c6996f"
|
|
58
58
|
}
|