@atlaskit/react-ufo 3.4.1 → 3.4.2
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/CHANGELOG.md +8 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +8 -2
- package/dist/cjs/create-payload/index.js +136 -76
- package/dist/cjs/segment/segment.js +29 -4
- package/dist/cjs/vc/vc-observer/index.js +71 -46
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +18 -11
- package/dist/cjs/vc/vc-observer-new/get-element-name.js +52 -64
- package/dist/cjs/vc/vc-observer-new/get-unique-element-name.js +80 -0
- package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +7 -2
- package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +6 -4
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +17 -9
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +8 -2
- package/dist/es2019/create-payload/index.js +39 -3
- package/dist/es2019/segment/segment.js +29 -3
- package/dist/es2019/vc/vc-observer/index.js +39 -12
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +14 -7
- package/dist/es2019/vc/vc-observer-new/get-element-name.js +51 -64
- package/dist/es2019/vc/vc-observer-new/get-unique-element-name.js +74 -0
- package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
- package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +6 -4
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +17 -9
- package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +8 -2
- package/dist/esm/create-payload/index.js +136 -76
- package/dist/esm/segment/segment.js +29 -4
- package/dist/esm/vc/vc-observer/index.js +71 -46
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +18 -11
- package/dist/esm/vc/vc-observer-new/get-element-name.js +52 -64
- package/dist/esm/vc/vc-observer-new/get-unique-element-name.js +74 -0
- package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
- package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +6 -4
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +17 -9
- package/dist/types/interaction-context/index.d.ts +2 -0
- package/dist/types/segment/segment.d.ts +2 -1
- package/dist/types/vc/vc-observer-new/get-unique-element-name.d.ts +8 -0
- package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +2 -0
- package/dist/types-ts4.5/segment/segment.d.ts +2 -1
- package/dist/types-ts4.5/vc/vc-observer-new/get-unique-element-name.d.ts +8 -0
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -0
- package/package.json +7 -1
|
@@ -103,7 +103,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
103
103
|
});
|
|
104
104
|
(0, _defineProperty2.default)(this, "getVCResult", /*#__PURE__*/function () {
|
|
105
105
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
|
|
106
|
-
var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, _VCObserver$calculate, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, isMultiHeatmapEnabled, revisionsData, isCalcSpeedIndexEnabled, speedIndex;
|
|
106
|
+
var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, _VCObserver$calculate, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, isVCClean, isMultiHeatmapEnabled, revisionsData, isCalcSpeedIndexEnabled, speedIndex;
|
|
107
107
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
108
108
|
while (1) switch (_context.prev = _context.next) {
|
|
109
109
|
case 0:
|
|
@@ -240,31 +240,54 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
240
240
|
} catch (e) {
|
|
241
241
|
/* do nothing */
|
|
242
242
|
}
|
|
243
|
+
isVCClean = !abortReasonInfo;
|
|
243
244
|
isMultiHeatmapEnabled = !(0, _platformFeatureFlags.fg)('platform_ufo_multiheatmap_killswitch');
|
|
244
|
-
revisionsData = isMultiHeatmapEnabled
|
|
245
|
+
revisionsData = isMultiHeatmapEnabled ? (0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new') ? (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [{
|
|
246
|
+
revision: 'fy25.01',
|
|
247
|
+
clean: isVCClean,
|
|
248
|
+
'metric:vc90': VC['90'],
|
|
249
|
+
vcDetails: Object.fromEntries(VCObserver.VCParts.map(function (key) {
|
|
250
|
+
var _VCBox$key;
|
|
251
|
+
return [key, {
|
|
252
|
+
t: VC[key],
|
|
253
|
+
e: (_VCBox$key = VCBox[key]) !== null && _VCBox$key !== void 0 ? _VCBox$key : []
|
|
254
|
+
}];
|
|
255
|
+
}))
|
|
256
|
+
}, {
|
|
257
|
+
revision: 'fy25.02',
|
|
258
|
+
clean: isVCClean,
|
|
259
|
+
'metric:vc90': vcNext.VC['90'],
|
|
260
|
+
vcDetails: Object.fromEntries(VCObserver.VCParts.map(function (key) {
|
|
261
|
+
var _vcNext$VCBox$key;
|
|
262
|
+
return [key, {
|
|
263
|
+
t: vcNext.VC[key],
|
|
264
|
+
e: (_vcNext$VCBox$key = vcNext.VCBox[key]) !== null && _vcNext$VCBox$key !== void 0 ? _vcNext$VCBox$key : []
|
|
265
|
+
}];
|
|
266
|
+
}))
|
|
267
|
+
}]) : multiHeatmap !== null ? (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), multiHeatmap === null || multiHeatmap === void 0 ? void 0 : multiHeatmap.getPayloadShapedData({
|
|
245
268
|
VCParts: VCObserver.VCParts.map(function (v) {
|
|
246
269
|
return parseInt(v);
|
|
247
270
|
}),
|
|
248
|
-
VCCalculationMethods: (0, _revisions.getRevisions)().map(function (
|
|
249
|
-
var classifier =
|
|
271
|
+
VCCalculationMethods: (0, _revisions.getRevisions)().map(function (_ref10) {
|
|
272
|
+
var classifier = _ref10.classifier;
|
|
250
273
|
return classifier.VCCalculationMethod;
|
|
251
274
|
}),
|
|
252
|
-
filterComponentsLog: (0, _revisions.getRevisions)().map(function (
|
|
253
|
-
var classifier =
|
|
275
|
+
filterComponentsLog: (0, _revisions.getRevisions)().map(function (_ref11) {
|
|
276
|
+
var classifier = _ref11.classifier;
|
|
254
277
|
return classifier.filterComponentsLog;
|
|
255
278
|
}),
|
|
256
279
|
isEventAborted: isEventAborted,
|
|
257
280
|
interactionStart: start,
|
|
258
281
|
ttai: stop,
|
|
259
282
|
ssr: ssr,
|
|
260
|
-
clean:
|
|
261
|
-
})) : null; // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
283
|
+
clean: isVCClean
|
|
284
|
+
})) : null : null; // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
262
285
|
isCalcSpeedIndexEnabled = (0, _platformFeatureFlags.fg)('ufo-calc-speed-index');
|
|
263
286
|
speedIndex = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "ufo:speedIndex", VCEntries.speedIndex), "ufo:next:speedIndex", vcNext.VCEntries.speedIndex);
|
|
264
287
|
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
265
288
|
'metrics:vc': VC
|
|
266
|
-
}, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"),
|
|
267
|
-
case
|
|
289
|
+
}, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), isVCClean), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:total"), totalPainted), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:next"), vcNext.VC), "".concat(fullPrefix, "vc:next:updates"), vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), isCalcSpeedIndexEnabled ? speedIndex : {}));
|
|
290
|
+
case 25:
|
|
268
291
|
case "end":
|
|
269
292
|
return _context.stop();
|
|
270
293
|
}
|
|
@@ -277,14 +300,16 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
277
300
|
(0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
|
|
278
301
|
_this.measureStart();
|
|
279
302
|
_this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
303
|
+
if (!(0, _platformFeatureFlags.fg)('platform_ufo_vc_observer_new')) {
|
|
304
|
+
_this.onViewportChangeDetected({
|
|
305
|
+
timestamp: rawTime,
|
|
306
|
+
intersectionRect: intersectionRect,
|
|
307
|
+
targetName: targetName,
|
|
308
|
+
element: element,
|
|
309
|
+
type: type,
|
|
310
|
+
ignoreReason: ignoreReason
|
|
311
|
+
});
|
|
312
|
+
}
|
|
288
313
|
_this.measureStop();
|
|
289
314
|
});
|
|
290
315
|
(0, _defineProperty2.default)(this, "legacyHandleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
|
|
@@ -309,13 +334,13 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
309
334
|
});
|
|
310
335
|
}
|
|
311
336
|
});
|
|
312
|
-
(0, _defineProperty2.default)(this, "onViewportChangeDetected", function (
|
|
313
|
-
var element =
|
|
314
|
-
type =
|
|
315
|
-
ignoreReason =
|
|
316
|
-
timestamp =
|
|
317
|
-
targetName =
|
|
318
|
-
intersectionRect =
|
|
337
|
+
(0, _defineProperty2.default)(this, "onViewportChangeDetected", function (_ref13) {
|
|
338
|
+
var element = _ref13.element,
|
|
339
|
+
type = _ref13.type,
|
|
340
|
+
ignoreReason = _ref13.ignoreReason,
|
|
341
|
+
timestamp = _ref13.timestamp,
|
|
342
|
+
targetName = _ref13.targetName,
|
|
343
|
+
intersectionRect = _ref13.intersectionRect;
|
|
319
344
|
if (_this.multiHeatmap === null) {
|
|
320
345
|
return;
|
|
321
346
|
}
|
|
@@ -397,10 +422,10 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
397
422
|
var unbinds = (0, _attachAbortListeners.attachAbortListeners)(window, _this.viewport, _this.abortReasonCallback);
|
|
398
423
|
if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
|
|
399
424
|
var _window2;
|
|
400
|
-
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (
|
|
401
|
-
var
|
|
402
|
-
key =
|
|
403
|
-
time =
|
|
425
|
+
Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref14) {
|
|
426
|
+
var _ref15 = (0, _slicedToArray2.default)(_ref14, 2),
|
|
427
|
+
key = _ref15[0],
|
|
428
|
+
time = _ref15[1];
|
|
404
429
|
if (time) {
|
|
405
430
|
_this.abortReasonCallback(key, time);
|
|
406
431
|
}
|
|
@@ -433,8 +458,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
433
458
|
}
|
|
434
459
|
return (0, _createClass2.default)(VCObserver, [{
|
|
435
460
|
key: "start",
|
|
436
|
-
value: function start(
|
|
437
|
-
var startTime =
|
|
461
|
+
value: function start(_ref16) {
|
|
462
|
+
var startTime = _ref16.startTime;
|
|
438
463
|
this.active = true;
|
|
439
464
|
if (this.observers.isBrowserSupported()) {
|
|
440
465
|
this.setViewportSize();
|
|
@@ -456,12 +481,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
456
481
|
}, {
|
|
457
482
|
key: "getIgnoredElements",
|
|
458
483
|
value: function getIgnoredElements(componentsLog) {
|
|
459
|
-
return Object.values(componentsLog).flat().filter(function (
|
|
460
|
-
var ignoreReason =
|
|
484
|
+
return Object.values(componentsLog).flat().filter(function (_ref17) {
|
|
485
|
+
var ignoreReason = _ref17.ignoreReason;
|
|
461
486
|
return Boolean(ignoreReason);
|
|
462
|
-
}).map(function (
|
|
463
|
-
var targetName =
|
|
464
|
-
ignoreReason =
|
|
487
|
+
}).map(function (_ref18) {
|
|
488
|
+
var targetName = _ref18.targetName,
|
|
489
|
+
ignoreReason = _ref18.ignoreReason;
|
|
465
490
|
return {
|
|
466
491
|
targetName: targetName,
|
|
467
492
|
ignoreReason: ignoreReason
|
|
@@ -581,12 +606,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
581
606
|
}
|
|
582
607
|
}], [{
|
|
583
608
|
key: "calculateVC",
|
|
584
|
-
value: function calculateVC(
|
|
585
|
-
var heatmap =
|
|
586
|
-
|
|
587
|
-
ssr =
|
|
588
|
-
componentsLog =
|
|
589
|
-
viewport =
|
|
609
|
+
value: function calculateVC(_ref19) {
|
|
610
|
+
var heatmap = _ref19.heatmap,
|
|
611
|
+
_ref19$ssr = _ref19.ssr,
|
|
612
|
+
ssr = _ref19$ssr === void 0 ? UNUSED_SECTOR : _ref19$ssr,
|
|
613
|
+
componentsLog = _ref19.componentsLog,
|
|
614
|
+
viewport = _ref19.viewport;
|
|
590
615
|
var lastUpdate = {};
|
|
591
616
|
var totalPainted = 0;
|
|
592
617
|
if (ssr !== UNUSED_SECTOR) {
|
|
@@ -655,11 +680,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
655
680
|
});
|
|
656
681
|
return VCRatio;
|
|
657
682
|
}, 0);
|
|
658
|
-
var VCEntries = entries.reduce(function (acc,
|
|
683
|
+
var VCEntries = entries.reduce(function (acc, _ref20, i) {
|
|
659
684
|
var _acc$abs, _componentsLog$timest, _acc$rel$vc, _acc$rel;
|
|
660
|
-
var
|
|
661
|
-
timestamp =
|
|
662
|
-
entryPainted =
|
|
685
|
+
var _ref21 = (0, _slicedToArray2.default)(_ref20, 2),
|
|
686
|
+
timestamp = _ref21[0],
|
|
687
|
+
entryPainted = _ref21[1];
|
|
663
688
|
var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
|
|
664
689
|
var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
|
|
665
690
|
var logEntry = (0, _toConsumableArray2.default)(new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
|
|
@@ -19,9 +19,10 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
19
19
|
(0, _defineProperty2.default)(this, "getSizeCallbacks", new Map());
|
|
20
20
|
(0, _defineProperty2.default)(this, "reactValidateCallbacks", new Map());
|
|
21
21
|
(0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref) {
|
|
22
|
+
var _this$intersectionObs;
|
|
22
23
|
var target = _ref.target,
|
|
23
24
|
boundingClientRect = _ref.boundingClientRect;
|
|
24
|
-
_this.intersectionObserver.unobserve(target);
|
|
25
|
+
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.unobserve(target);
|
|
25
26
|
if (!(target instanceof HTMLElement)) {
|
|
26
27
|
// impossible case - keep typescript healthy
|
|
27
28
|
return;
|
|
@@ -68,18 +69,21 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
68
69
|
_this.reactValidateCallbacks.delete(staticKey);
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
if (typeof IntersectionObserver === 'function') {
|
|
73
|
+
// Only instantiate the IntersectionObserver if it's supported
|
|
74
|
+
this.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
75
|
+
return entries.filter(function (entry) {
|
|
76
|
+
return entry.intersectionRatio > 0;
|
|
77
|
+
}).forEach(_this.intersectionObserverCallback);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
76
80
|
if (window.document) {
|
|
77
81
|
try {
|
|
78
82
|
var existingElements = document.querySelectorAll('[data-ssr-placeholder]');
|
|
79
83
|
existingElements.forEach(function (el) {
|
|
80
84
|
var _el$dataset;
|
|
81
85
|
if (el instanceof HTMLElement && el !== null && el !== void 0 && (_el$dataset = el.dataset) !== null && _el$dataset !== void 0 && _el$dataset.ssrPlaceholder) {
|
|
82
|
-
var _window$__SSR_PLACEHO;
|
|
86
|
+
var _window$__SSR_PLACEHO, _this$intersectionObs2;
|
|
83
87
|
var width = -1;
|
|
84
88
|
var height = -1;
|
|
85
89
|
var x = -1;
|
|
@@ -97,7 +101,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
97
101
|
x: x,
|
|
98
102
|
y: y
|
|
99
103
|
});
|
|
100
|
-
_this.intersectionObserver.observe(el);
|
|
104
|
+
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.observe(el);
|
|
101
105
|
}
|
|
102
106
|
});
|
|
103
107
|
} catch (e) {} finally {
|
|
@@ -157,8 +161,9 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
157
161
|
resolve(false);
|
|
158
162
|
return;
|
|
159
163
|
} else {
|
|
164
|
+
var _this2$intersectionOb;
|
|
160
165
|
_this2.callbacks.set(id, resolve);
|
|
161
|
-
_this2.intersectionObserver.observe(el);
|
|
166
|
+
(_this2$intersectionOb = _this2.intersectionObserver) === null || _this2$intersectionOb === void 0 || _this2$intersectionOb.observe(el);
|
|
162
167
|
}
|
|
163
168
|
});
|
|
164
169
|
}
|
|
@@ -167,8 +172,9 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
167
172
|
value: function getSize(el) {
|
|
168
173
|
var _this3 = this;
|
|
169
174
|
return new Promise(function (resolve) {
|
|
175
|
+
var _this3$intersectionOb;
|
|
170
176
|
_this3.getSizeCallbacks.set(el.dataset.ssrPlaceholder || '', resolve);
|
|
171
|
-
_this3.intersectionObserver.observe(el);
|
|
177
|
+
(_this3$intersectionOb = _this3.intersectionObserver) === null || _this3$intersectionOb === void 0 || _this3$intersectionOb.observe(el);
|
|
172
178
|
});
|
|
173
179
|
}
|
|
174
180
|
}, {
|
|
@@ -182,8 +188,9 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
|
|
|
182
188
|
resolve(false);
|
|
183
189
|
return;
|
|
184
190
|
} else {
|
|
191
|
+
var _this4$intersectionOb;
|
|
185
192
|
_this4.reactValidateCallbacks.set(id, resolve);
|
|
186
|
-
_this4.intersectionObserver.observe(el);
|
|
193
|
+
(_this4$intersectionOb = _this4.intersectionObserver) === null || _this4$intersectionOb === void 0 || _this4$intersectionOb.observe(el);
|
|
187
194
|
}
|
|
188
195
|
});
|
|
189
196
|
}
|
|
@@ -5,67 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getElementName;
|
|
7
7
|
var nameCache = new WeakMap();
|
|
8
|
-
function getAttributeSelector(element, attributeName) {
|
|
9
|
-
var attrValue = element.getAttribute(attributeName);
|
|
10
|
-
if (!attrValue) {
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
return "[".concat(attributeName, "=\"").concat(attrValue, "\"]");
|
|
14
|
-
}
|
|
15
|
-
function isValidSelector(selector) {
|
|
16
|
-
try {
|
|
17
|
-
document.querySelector(selector);
|
|
18
|
-
return true;
|
|
19
|
-
} catch (err) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function isSelectorUnique(selector) {
|
|
24
|
-
return document.querySelectorAll(selector).length === 1;
|
|
25
|
-
}
|
|
26
|
-
function getUniqueSelector(selectorConfig, element) {
|
|
27
|
-
var currentElement = element;
|
|
28
|
-
var parts = [];
|
|
29
|
-
var MAX_DEPTH = 3;
|
|
30
|
-
var currentDepth = 0;
|
|
31
|
-
while (currentElement && currentElement.localName !== 'body' && currentDepth <= MAX_DEPTH) {
|
|
32
|
-
var tagName = currentElement.localName;
|
|
33
|
-
var selectorPart = tagName;
|
|
34
|
-
if (selectorConfig.id && currentElement.id && isValidSelector("#".concat(currentElement.id))) {
|
|
35
|
-
selectorPart += "#".concat(currentElement.id);
|
|
36
|
-
} else if (selectorConfig.dataVC) {
|
|
37
|
-
selectorPart += getAttributeSelector(currentElement, 'data-vc');
|
|
38
|
-
} else if (selectorConfig.testId) {
|
|
39
|
-
selectorPart += getAttributeSelector(currentElement, 'data-testid') || getAttributeSelector(currentElement, 'data-test-id');
|
|
40
|
-
} else if (selectorConfig.role) {
|
|
41
|
-
selectorPart += getAttributeSelector(currentElement, 'role');
|
|
42
|
-
} else if (selectorConfig.className && currentElement.className) {
|
|
43
|
-
var classNames = Array.from(currentElement.classList).join('.');
|
|
44
|
-
if (classNames) {
|
|
45
|
-
if (isValidSelector(".".concat(classNames))) {
|
|
46
|
-
selectorPart += ".".concat(classNames);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
parts.unshift(selectorPart);
|
|
51
|
-
var _potentialSelector = parts.join(' > ').trim();
|
|
52
|
-
if (_potentialSelector && isSelectorUnique(_potentialSelector)) {
|
|
53
|
-
return _potentialSelector;
|
|
54
|
-
}
|
|
55
|
-
currentElement = currentElement.parentElement;
|
|
56
|
-
currentDepth++;
|
|
57
|
-
}
|
|
58
|
-
var potentialSelector = parts.join(' > ').trim();
|
|
59
|
-
if (!potentialSelector) {
|
|
60
|
-
return 'unknown';
|
|
61
|
-
} else if (!isSelectorUnique(potentialSelector)) {
|
|
62
|
-
var parentElement = element.parentElement;
|
|
63
|
-
if (parentElement) {
|
|
64
|
-
return "".concat(potentialSelector, ":nth-child"); // NOTE: invalid DOM selector, but enough information for VC
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return potentialSelector;
|
|
68
|
-
}
|
|
69
8
|
function getElementName(selectorConfig, element) {
|
|
70
9
|
if (!(element instanceof HTMLElement)) {
|
|
71
10
|
return 'error';
|
|
@@ -74,7 +13,56 @@ function getElementName(selectorConfig, element) {
|
|
|
74
13
|
if (cachedName) {
|
|
75
14
|
return cachedName;
|
|
76
15
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
16
|
+
// Get the tag name of the element.
|
|
17
|
+
var tagName = element.localName;
|
|
18
|
+
var encodeValue = function encodeValue(s) {
|
|
19
|
+
try {
|
|
20
|
+
return encodeURIComponent(s);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return 'malformed_value';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Helper function to construct attribute selectors.
|
|
27
|
+
var getAttributeSelector = function getAttributeSelector(attributeName) {
|
|
28
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
29
|
+
var attrValue = element.getAttribute(attributeName);
|
|
30
|
+
if (!attrValue) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
var encondedAttrValue = encodeValue(attrValue);
|
|
34
|
+
return "".concat(prefix, "[").concat(attributeName, "=\"").concat(encondedAttrValue, "\"]");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Construct the data-vc attribute selector if specified in the config.
|
|
38
|
+
var dataVC = selectorConfig.dataVC ? getAttributeSelector('data-vc') : '';
|
|
39
|
+
|
|
40
|
+
// Construct the ID selector if specified in the config and the element has an ID.
|
|
41
|
+
var id = selectorConfig.id && element.id ? "#".concat(encodeValue(element.id)) : '';
|
|
42
|
+
|
|
43
|
+
// Construct the test ID selector if specified in the config.
|
|
44
|
+
var testId = selectorConfig.testId ? getAttributeSelector('data-testid') || getAttributeSelector('data-test-id') : '';
|
|
45
|
+
|
|
46
|
+
// Construct the role selector if specified in the config.
|
|
47
|
+
var role = selectorConfig.role ? getAttributeSelector('role') : '';
|
|
48
|
+
var classNames = Array.from(element.classList).map(encodeValue).join('.');
|
|
49
|
+
// Construct the class list selector if specified in the config.
|
|
50
|
+
var classList = selectorConfig.className && classNames ? ".".concat(classNames) : '';
|
|
51
|
+
|
|
52
|
+
// Combine primary attribute selectors (id, testId, role) into a single string.
|
|
53
|
+
var primaryAttributes = [id, testId, role].filter(Boolean).join('');
|
|
54
|
+
|
|
55
|
+
// Use dataVC if available, otherwise use the primary attributes.
|
|
56
|
+
var attributes = dataVC || primaryAttributes;
|
|
57
|
+
|
|
58
|
+
// If no attributes or class list, recursively get the parent's name.
|
|
59
|
+
if (!attributes && !classList) {
|
|
60
|
+
var parentName = element.parentElement ? getElementName(selectorConfig, element.parentElement) : 'unknown';
|
|
61
|
+
return "".concat(parentName, " > ").concat(tagName);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Return the final constructed name: tagName + attributes or classList.
|
|
65
|
+
var name = "".concat(tagName).concat(attributes || classList);
|
|
66
|
+
nameCache.set(element, name);
|
|
67
|
+
return name;
|
|
80
68
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getElementName;
|
|
7
|
+
var nameCache = new WeakMap();
|
|
8
|
+
function getAttributeSelector(element, attributeName) {
|
|
9
|
+
var attrValue = element.getAttribute(attributeName);
|
|
10
|
+
if (!attrValue) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
return "[".concat(attributeName, "=\"").concat(attrValue, "\"]");
|
|
14
|
+
}
|
|
15
|
+
function isValidSelector(selector) {
|
|
16
|
+
try {
|
|
17
|
+
document.querySelector(selector);
|
|
18
|
+
return true;
|
|
19
|
+
} catch (err) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isSelectorUnique(selector) {
|
|
24
|
+
return document.querySelectorAll(selector).length === 1;
|
|
25
|
+
}
|
|
26
|
+
function getUniqueSelector(selectorConfig, element) {
|
|
27
|
+
var currentElement = element;
|
|
28
|
+
var parts = [];
|
|
29
|
+
var MAX_DEPTH = 3;
|
|
30
|
+
var currentDepth = 0;
|
|
31
|
+
while (currentElement && currentElement.localName !== 'body' && currentDepth <= MAX_DEPTH) {
|
|
32
|
+
var tagName = currentElement.localName;
|
|
33
|
+
var selectorPart = tagName;
|
|
34
|
+
if (selectorConfig.id && currentElement.id && isValidSelector("#".concat(currentElement.id))) {
|
|
35
|
+
selectorPart += "#".concat(currentElement.id);
|
|
36
|
+
} else if (selectorConfig.dataVC) {
|
|
37
|
+
selectorPart += getAttributeSelector(currentElement, 'data-vc');
|
|
38
|
+
} else if (selectorConfig.testId) {
|
|
39
|
+
selectorPart += getAttributeSelector(currentElement, 'data-testid') || getAttributeSelector(currentElement, 'data-test-id');
|
|
40
|
+
} else if (selectorConfig.role) {
|
|
41
|
+
selectorPart += getAttributeSelector(currentElement, 'role');
|
|
42
|
+
} else if (selectorConfig.className && currentElement.className) {
|
|
43
|
+
var classNames = Array.from(currentElement.classList).join('.');
|
|
44
|
+
if (classNames) {
|
|
45
|
+
if (isValidSelector(".".concat(classNames))) {
|
|
46
|
+
selectorPart += ".".concat(classNames);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
parts.unshift(selectorPart);
|
|
51
|
+
var _potentialSelector = parts.join(' > ').trim();
|
|
52
|
+
if (_potentialSelector && isSelectorUnique(_potentialSelector)) {
|
|
53
|
+
return _potentialSelector;
|
|
54
|
+
}
|
|
55
|
+
currentElement = currentElement.parentElement;
|
|
56
|
+
currentDepth++;
|
|
57
|
+
}
|
|
58
|
+
var potentialSelector = parts.join(' > ').trim();
|
|
59
|
+
if (!potentialSelector) {
|
|
60
|
+
return 'unknown';
|
|
61
|
+
} else if (!isSelectorUnique(potentialSelector)) {
|
|
62
|
+
var parentElement = element.parentElement;
|
|
63
|
+
if (parentElement) {
|
|
64
|
+
return "".concat(potentialSelector, ":nth-child"); // NOTE: invalid DOM selector, but enough information for VC
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return potentialSelector;
|
|
68
|
+
}
|
|
69
|
+
function getElementName(selectorConfig, element) {
|
|
70
|
+
if (!(element instanceof HTMLElement)) {
|
|
71
|
+
return 'error';
|
|
72
|
+
}
|
|
73
|
+
var cachedName = nameCache.get(element);
|
|
74
|
+
if (cachedName) {
|
|
75
|
+
return cachedName;
|
|
76
|
+
}
|
|
77
|
+
var uniqueSelector = getUniqueSelector(selectorConfig, element);
|
|
78
|
+
nameCache.set(element, uniqueSelector);
|
|
79
|
+
return uniqueSelector;
|
|
80
|
+
}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.default = exports.KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -17,6 +17,11 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
17
17
|
var ABORTING_WINDOW_EVENT = ['wheel', 'scroll', 'keydown', 'resize'];
|
|
18
18
|
var REVISION_NO = 'fy25.03';
|
|
19
19
|
var CONSIDERED_ENTRY_TYPE = ['mutation:child-element', 'mutation:element', 'mutation:attribute', 'layout-shift', 'window:event'];
|
|
20
|
+
|
|
21
|
+
// TODO: AFO-3523
|
|
22
|
+
// Those are the attributes we have found when testing the 'fy25.03' manually.
|
|
23
|
+
// We still need to replace this hardcoded list with a proper automation
|
|
24
|
+
var KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS = exports.KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS = ['data-drop-target-for-element', 'draggable'];
|
|
20
25
|
var VCCalculator_FY25_03 = exports.default = /*#__PURE__*/function (_AbstractVCCalculator) {
|
|
21
26
|
function VCCalculator_FY25_03() {
|
|
22
27
|
(0, _classCallCheck2.default)(this, VCCalculator_FY25_03);
|
|
@@ -32,7 +37,7 @@ var VCCalculator_FY25_03 = exports.default = /*#__PURE__*/function (_AbstractVCC
|
|
|
32
37
|
if (entry.type === 'mutation:attribute') {
|
|
33
38
|
var entryData = entry.data;
|
|
34
39
|
var attributeName = entryData.attributeName;
|
|
35
|
-
if (!attributeName) {
|
|
40
|
+
if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
|
|
36
41
|
return false;
|
|
37
42
|
}
|
|
38
43
|
return true;
|
package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js
CHANGED
|
@@ -41,12 +41,14 @@ var ViewportCanvas = exports.ViewportCanvas = /*#__PURE__*/function () {
|
|
|
41
41
|
this.scaleFactor = scaleFactor;
|
|
42
42
|
this.colorCounter = 1;
|
|
43
43
|
this.colorTimeMap = new Map();
|
|
44
|
+
var safeViewportWidth = Math.max(viewport.width, 1);
|
|
45
|
+
var safeViewportHeight = Math.max(viewport.height, 1);
|
|
44
46
|
|
|
45
47
|
// Calculate scaled dimensions
|
|
46
|
-
this.scaledWidth = Math.ceil(
|
|
47
|
-
this.scaledHeight = Math.ceil(
|
|
48
|
-
this.scaleX = this.scaledWidth /
|
|
49
|
-
this.scaleY = this.scaledHeight /
|
|
48
|
+
this.scaledWidth = Math.max(Math.ceil(safeViewportWidth * scaleFactor), 1);
|
|
49
|
+
this.scaledHeight = Math.max(Math.ceil(safeViewportHeight * scaleFactor), 1);
|
|
50
|
+
this.scaleX = this.scaledWidth / safeViewportWidth;
|
|
51
|
+
this.scaleY = this.scaledHeight / safeViewportHeight;
|
|
50
52
|
|
|
51
53
|
// Initialize OffscreenCanvas with scaled dimensions
|
|
52
54
|
this.canvas = document.createElement('canvas');
|
|
@@ -21,7 +21,9 @@ function isElementVisible(element) {
|
|
|
21
21
|
try {
|
|
22
22
|
var visible = element.checkVisibility({
|
|
23
23
|
// @ts-expect-error
|
|
24
|
-
visibilityProperty: true
|
|
24
|
+
visibilityProperty: true,
|
|
25
|
+
contentVisibilityAuto: true,
|
|
26
|
+
opacityProperty: true
|
|
25
27
|
});
|
|
26
28
|
return visible;
|
|
27
29
|
} catch (e) {
|
|
@@ -54,6 +56,9 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
54
56
|
time = _ref2.time,
|
|
55
57
|
type = _ref2.type,
|
|
56
58
|
mutationData = _ref2.mutationData;
|
|
59
|
+
if (!target) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
57
62
|
var visible = isElementVisible(target);
|
|
58
63
|
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
59
64
|
_this.mapVisibleNodeRects.set(target, rect);
|
|
@@ -149,14 +154,17 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
149
154
|
try {
|
|
150
155
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
151
156
|
var changedRect = _step.value;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
var target = changedRect.node;
|
|
158
|
+
if (target) {
|
|
159
|
+
onChange({
|
|
160
|
+
time: time,
|
|
161
|
+
elementRef: new WeakRef(target),
|
|
162
|
+
visible: true,
|
|
163
|
+
rect: changedRect.rect,
|
|
164
|
+
previousRect: changedRect.previousRect,
|
|
165
|
+
type: 'layout-shift'
|
|
166
|
+
});
|
|
167
|
+
}
|
|
160
168
|
}
|
|
161
169
|
} catch (err) {
|
|
162
170
|
_iterator.e(err);
|
|
@@ -2,6 +2,10 @@ import { PerformanceObserverEntryTypes } from '../../const';
|
|
|
2
2
|
import { EntriesBuffer } from '../buffer';
|
|
3
3
|
let pe = null;
|
|
4
4
|
const getObserver = () => {
|
|
5
|
+
if (typeof PerformanceObserver !== 'function') {
|
|
6
|
+
// Only instantiate the IntersectionObserver if it's supported
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
5
9
|
if (pe !== null) {
|
|
6
10
|
return pe;
|
|
7
11
|
}
|
|
@@ -18,13 +22,15 @@ const getObserver = () => {
|
|
|
18
22
|
return pe;
|
|
19
23
|
};
|
|
20
24
|
export const startLSObserver = () => {
|
|
21
|
-
|
|
25
|
+
var _getObserver;
|
|
26
|
+
(_getObserver = getObserver()) === null || _getObserver === void 0 ? void 0 : _getObserver.observe({
|
|
22
27
|
type: PerformanceObserverEntryTypes.LayoutShift,
|
|
23
28
|
buffered: true
|
|
24
29
|
});
|
|
25
30
|
};
|
|
26
31
|
export const startLTObserver = () => {
|
|
27
|
-
|
|
32
|
+
var _getObserver2;
|
|
33
|
+
(_getObserver2 = getObserver()) === null || _getObserver2 === void 0 ? void 0 : _getObserver2.observe({
|
|
28
34
|
type: PerformanceObserverEntryTypes.LongTask,
|
|
29
35
|
buffered: true
|
|
30
36
|
});
|