@atlaskit/react-ufo 4.3.0 → 4.3.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 +14 -0
- package/dist/cjs/resource-timing/main.js +1 -2
- package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +31 -23
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +29 -13
- package/dist/cjs/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +9 -0
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-display-content.js +48 -0
- package/dist/es2019/resource-timing/main.js +1 -2
- package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +8 -0
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +16 -6
- package/dist/es2019/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +9 -0
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-display-content.js +27 -0
- package/dist/esm/resource-timing/main.js +1 -2
- package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +31 -23
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +29 -13
- package/dist/esm/vc/vc-observer-new/viewport-observer/intersection-observer/index.js +9 -0
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-display-content.js +39 -0
- package/dist/types/common/vc/types.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-display-content.d.ts +4 -0
- package/dist/types-ts4.5/common/vc/types.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-display-content.d.ts +4 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 4.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7cf45d7a0ce8d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7cf45d7a0ce8d) -
|
|
8
|
+
Include elements with display:contents css property in TTVC
|
|
9
|
+
|
|
10
|
+
## 4.3.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`3f6614a936a5e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f6614a936a5e) -
|
|
15
|
+
Send vc100
|
|
16
|
+
|
|
3
17
|
## 4.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getResourceTimings = getResourceTimings;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
var _config = require("../config");
|
|
11
10
|
var _roundNumber = require("../round-number");
|
|
12
11
|
var _config2 = require("./common/utils/config");
|
|
@@ -102,7 +101,7 @@ function getNetworkData(item, eventStart) {
|
|
|
102
101
|
ttfb: ttfb,
|
|
103
102
|
serverTime: serverTime,
|
|
104
103
|
networkTime: networkTime,
|
|
105
|
-
requestStart:
|
|
104
|
+
requestStart: requestStartRelative
|
|
106
105
|
}, getSizeObject(transferSize));
|
|
107
106
|
}
|
|
108
107
|
function getResourceTimings(interactionStart, interactionEnd) {
|
|
@@ -12,6 +12,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _checkDisplayContent = require("../viewport-observer/utils/check-display-content");
|
|
15
17
|
var _percentileCalc = require("./percentile-calc");
|
|
16
18
|
var _getViewportHeight = _interopRequireDefault(require("./utils/get-viewport-height"));
|
|
17
19
|
var _getViewportWidth = _interopRequireDefault(require("./utils/get-viewport-width"));
|
|
@@ -90,8 +92,11 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
90
92
|
while (1) switch (_context.prev = _context.next) {
|
|
91
93
|
case 0:
|
|
92
94
|
percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
|
|
95
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_send_vc_100')) {
|
|
96
|
+
percentiles.push(100);
|
|
97
|
+
}
|
|
93
98
|
viewportEntries = this.filterViewportEntries(filteredEntries);
|
|
94
|
-
_context.next =
|
|
99
|
+
_context.next = 5;
|
|
95
100
|
return (0, _percentileCalc.calculateTTVCPercentilesWithDebugInfo)({
|
|
96
101
|
viewport: {
|
|
97
102
|
width: (0, _getViewportWidth.default)(),
|
|
@@ -101,31 +106,31 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
101
106
|
stopTime: stopTime,
|
|
102
107
|
orderedEntries: viewportEntries
|
|
103
108
|
});
|
|
104
|
-
case
|
|
109
|
+
case 5:
|
|
105
110
|
vcLogs = _context.sent;
|
|
106
111
|
vcDetails = {};
|
|
107
112
|
percentileIndex = 0;
|
|
108
113
|
entryDataBuffer = new Set();
|
|
109
114
|
if (!vcLogs) {
|
|
110
|
-
_context.next =
|
|
115
|
+
_context.next = 29;
|
|
111
116
|
break;
|
|
112
117
|
}
|
|
113
118
|
_iterator3 = _createForOfIteratorHelper(vcLogs);
|
|
114
|
-
_context.prev =
|
|
119
|
+
_context.prev = 11;
|
|
115
120
|
_iterator3.s();
|
|
116
|
-
case
|
|
121
|
+
case 13:
|
|
117
122
|
if ((_step3 = _iterator3.n()).done) {
|
|
118
|
-
_context.next =
|
|
123
|
+
_context.next = 21;
|
|
119
124
|
break;
|
|
120
125
|
}
|
|
121
126
|
_entry2 = _step3.value;
|
|
122
127
|
time = _entry2.time, viewportPercentage = _entry2.viewportPercentage, entries = _entry2.entries; // Only process entries if we haven't reached all percentiles
|
|
123
128
|
if (!(percentileIndex >= percentiles.length)) {
|
|
124
|
-
_context.next =
|
|
129
|
+
_context.next = 18;
|
|
125
130
|
break;
|
|
126
131
|
}
|
|
127
|
-
return _context.abrupt("break",
|
|
128
|
-
case
|
|
132
|
+
return _context.abrupt("break", 21);
|
|
133
|
+
case 18:
|
|
129
134
|
// Check if this entry matches any checkpoint percentiles
|
|
130
135
|
if (viewportPercentage >= percentiles[percentileIndex]) {
|
|
131
136
|
elementNames = entries.map(function (e) {
|
|
@@ -147,21 +152,21 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
147
152
|
return entryDataBuffer.add(e);
|
|
148
153
|
});
|
|
149
154
|
}
|
|
150
|
-
case
|
|
151
|
-
_context.next =
|
|
155
|
+
case 19:
|
|
156
|
+
_context.next = 13;
|
|
152
157
|
break;
|
|
153
|
-
case
|
|
154
|
-
_context.next =
|
|
158
|
+
case 21:
|
|
159
|
+
_context.next = 26;
|
|
155
160
|
break;
|
|
156
|
-
case
|
|
157
|
-
_context.prev =
|
|
158
|
-
_context.t0 = _context["catch"](
|
|
161
|
+
case 23:
|
|
162
|
+
_context.prev = 23;
|
|
163
|
+
_context.t0 = _context["catch"](11);
|
|
159
164
|
_iterator3.e(_context.t0);
|
|
160
|
-
case
|
|
161
|
-
_context.prev =
|
|
165
|
+
case 26:
|
|
166
|
+
_context.prev = 26;
|
|
162
167
|
_iterator3.f();
|
|
163
|
-
return _context.finish(
|
|
164
|
-
case
|
|
168
|
+
return _context.finish(26);
|
|
169
|
+
case 29:
|
|
165
170
|
// Fill in any missing percentiles with the last known values
|
|
166
171
|
previousResult = {
|
|
167
172
|
t: 0,
|
|
@@ -300,11 +305,11 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
300
305
|
}
|
|
301
306
|
}
|
|
302
307
|
return _context.abrupt("return", vcDetails);
|
|
303
|
-
case
|
|
308
|
+
case 39:
|
|
304
309
|
case "end":
|
|
305
310
|
return _context.stop();
|
|
306
311
|
}
|
|
307
|
-
}, _callee, this, [[
|
|
312
|
+
}, _callee, this, [[11, 23, 26, 29]]);
|
|
308
313
|
}));
|
|
309
314
|
function calculateWithDebugInfo(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
310
315
|
return _calculateWithDebugInfo.apply(this, arguments);
|
|
@@ -351,8 +356,11 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
351
356
|
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
352
357
|
};
|
|
353
358
|
result.ratios = this.calculateRatios(filteredEntries);
|
|
359
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
360
|
+
result.childrenIgnoredCount = (0, _checkDisplayContent.getInvalidChildrenCount)();
|
|
361
|
+
}
|
|
354
362
|
return _context2.abrupt("return", result);
|
|
355
|
-
case
|
|
363
|
+
case 14:
|
|
356
364
|
case "end":
|
|
357
365
|
return _context2.stop();
|
|
358
366
|
}
|
|
@@ -18,6 +18,7 @@ var _rllPlaceholders = require("../../vc-observer/observers/rll-placeholders");
|
|
|
18
18
|
var _intersectionObserver = require("./intersection-observer");
|
|
19
19
|
var _mutationObserver = _interopRequireDefault(require("./mutation-observer"));
|
|
20
20
|
var _performanceObserver = _interopRequireDefault(require("./performance-observer"));
|
|
21
|
+
var _checkDisplayContent = _interopRequireDefault(require("./utils/check-display-content"));
|
|
21
22
|
var _checkWithinComponent2 = _interopRequireWildcard(require("./utils/check-within-component"));
|
|
22
23
|
var _isInVcIgnoreIfNoLayoutShiftMarker = _interopRequireDefault(require("./utils/is-in-vc-ignore-if-no-layout-shift-marker"));
|
|
23
24
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -123,8 +124,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
123
124
|
_iterator = _createForOfIteratorHelper(addedNodes);
|
|
124
125
|
_context2.prev = 4;
|
|
125
126
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
126
|
-
var _this$intersectionObs9;
|
|
127
|
-
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8;
|
|
127
|
+
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8, validTargets, _iterator2, _step2, _this$intersectionObs9, validTarget, _this$intersectionObs0;
|
|
128
128
|
return _regenerator.default.wrap(function _loop$(_context) {
|
|
129
129
|
while (1) switch (_context.prev = _context.next) {
|
|
130
130
|
case 0:
|
|
@@ -254,7 +254,23 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
254
254
|
(_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
|
|
255
255
|
return _context.abrupt("return", 0);
|
|
256
256
|
case 54:
|
|
257
|
-
(
|
|
257
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
258
|
+
// Check if the target has display:content css property, return array of valid targets
|
|
259
|
+
validTargets = (0, _checkDisplayContent.default)(addedNode);
|
|
260
|
+
_iterator2 = _createForOfIteratorHelper(validTargets);
|
|
261
|
+
try {
|
|
262
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
263
|
+
validTarget = _step2.value;
|
|
264
|
+
(_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
|
|
265
|
+
}
|
|
266
|
+
} catch (err) {
|
|
267
|
+
_iterator2.e(err);
|
|
268
|
+
} finally {
|
|
269
|
+
_iterator2.f();
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
(_this$intersectionObs0 = _this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
273
|
+
}
|
|
258
274
|
case 55:
|
|
259
275
|
case "end":
|
|
260
276
|
return _context.stop();
|
|
@@ -300,12 +316,12 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
300
316
|
};
|
|
301
317
|
}());
|
|
302
318
|
(0, _defineProperty2.default)(this, "handleAttributeMutation", function (_ref6) {
|
|
303
|
-
var _this$
|
|
319
|
+
var _this$intersectionObs1;
|
|
304
320
|
var target = _ref6.target,
|
|
305
321
|
attributeName = _ref6.attributeName,
|
|
306
322
|
oldValue = _ref6.oldValue,
|
|
307
323
|
newValue = _ref6.newValue;
|
|
308
|
-
(_this$
|
|
324
|
+
(_this$intersectionObs1 = _this.intersectionObserver) === null || _this$intersectionObs1 === void 0 || _this$intersectionObs1.watchAndTag(target, function (_ref7) {
|
|
309
325
|
var target = _ref7.target,
|
|
310
326
|
rect = _ref7.rect;
|
|
311
327
|
if ((0, _vcUtils.isContainedWithinMediaWrapper)(target)) {
|
|
@@ -368,11 +384,11 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
368
384
|
(0, _defineProperty2.default)(this, "handleLayoutShift", function (_ref8) {
|
|
369
385
|
var time = _ref8.time,
|
|
370
386
|
changedRects = _ref8.changedRects;
|
|
371
|
-
var
|
|
372
|
-
|
|
387
|
+
var _iterator3 = _createForOfIteratorHelper(changedRects),
|
|
388
|
+
_step3;
|
|
373
389
|
try {
|
|
374
|
-
for (
|
|
375
|
-
var changedRect =
|
|
390
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
391
|
+
var changedRect = _step3.value;
|
|
376
392
|
var target = changedRect.node;
|
|
377
393
|
if (target) {
|
|
378
394
|
_this.onChange({
|
|
@@ -386,9 +402,9 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
386
402
|
}
|
|
387
403
|
}
|
|
388
404
|
} catch (err) {
|
|
389
|
-
|
|
405
|
+
_iterator3.e(err);
|
|
390
406
|
} finally {
|
|
391
|
-
|
|
407
|
+
_iterator3.f();
|
|
392
408
|
}
|
|
393
409
|
});
|
|
394
410
|
this.mapVisibleNodeRects = new WeakMap();
|
|
@@ -445,12 +461,12 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
445
461
|
}, {
|
|
446
462
|
key: "stop",
|
|
447
463
|
value: function stop() {
|
|
448
|
-
var _this$mutationObserve2, _this$
|
|
464
|
+
var _this$mutationObserve2, _this$intersectionObs10, _this$performanceObse2;
|
|
449
465
|
if (!this.isStarted) {
|
|
450
466
|
return;
|
|
451
467
|
}
|
|
452
468
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
453
|
-
(_this$
|
|
469
|
+
(_this$intersectionObs10 = this.intersectionObserver) === null || _this$intersectionObs10 === void 0 || _this$intersectionObs10.disconnect();
|
|
454
470
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
|
|
455
471
|
this.isStarted = false;
|
|
456
472
|
// Clean up caches when stopping
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createIntersectionObserver = createIntersectionObserver;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _checkDisplayContent = require("../utils/check-display-content");
|
|
7
9
|
function isValidEntry(entry) {
|
|
8
10
|
return entry.isIntersecting && entry.intersectionRect.width > 0 && entry.intersectionRect.height > 0;
|
|
9
11
|
}
|
|
@@ -19,6 +21,13 @@ function createIntersectionObserver(_ref) {
|
|
|
19
21
|
var startTime = performance.now();
|
|
20
22
|
entries.forEach(function (entry) {
|
|
21
23
|
if (!(entry.target instanceof HTMLElement) || !isValidEntry(entry)) {
|
|
24
|
+
// TODO: Remove this logic when analysis is complete
|
|
25
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
26
|
+
if (entry.target instanceof HTMLElement && !isValidEntry(entry) && _checkDisplayContent.checkedChildrenCache.get(entry.target) === false) {
|
|
27
|
+
(0, _checkDisplayContent.incrementCheckedInvalidChildrenCount)();
|
|
28
|
+
_checkDisplayContent.checkedChildrenCache.set(entry.target, true);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
22
31
|
return;
|
|
23
32
|
}
|
|
24
33
|
var mutationTag = null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkedChildrenCache = void 0;
|
|
7
|
+
exports.default = checkCssProperty;
|
|
8
|
+
exports.getInvalidChildrenCount = getInvalidChildrenCount;
|
|
9
|
+
exports.incrementCheckedInvalidChildrenCount = incrementCheckedInvalidChildrenCount;
|
|
10
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
11
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
// TODO: Remove this cache when analysis is complete - it is used to track whether direct children elements will be ignored by the observer
|
|
14
|
+
var checkedChildrenCache = exports.checkedChildrenCache = new WeakMap();
|
|
15
|
+
var checkedInvalidChildrenCount = 0;
|
|
16
|
+
function incrementCheckedInvalidChildrenCount() {
|
|
17
|
+
checkedInvalidChildrenCount++;
|
|
18
|
+
}
|
|
19
|
+
function getInvalidChildrenCount() {
|
|
20
|
+
return checkedInvalidChildrenCount;
|
|
21
|
+
}
|
|
22
|
+
function checkCssProperty(element) {
|
|
23
|
+
var computedStyle = window.getComputedStyle(element);
|
|
24
|
+
if (computedStyle.display === 'contents') {
|
|
25
|
+
// If display is 'contents', we return the direct children of the element
|
|
26
|
+
var result = [];
|
|
27
|
+
var _iterator = _createForOfIteratorHelper(element.children),
|
|
28
|
+
_step;
|
|
29
|
+
try {
|
|
30
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
31
|
+
var child = _step.value;
|
|
32
|
+
if (child instanceof HTMLElement) {
|
|
33
|
+
if (!checkedChildrenCache.has(child)) {
|
|
34
|
+
// TODO: Remove this cache when analysis is complete
|
|
35
|
+
checkedChildrenCache.set(child, false);
|
|
36
|
+
}
|
|
37
|
+
result.push(child);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
_iterator.e(err);
|
|
42
|
+
} finally {
|
|
43
|
+
_iterator.f();
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
return [element];
|
|
48
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { getConfig as getConfigUFO } from '../config';
|
|
3
2
|
import { roundEpsilon } from '../round-number';
|
|
4
3
|
import { getConfig } from './common/utils/config';
|
|
@@ -94,7 +93,7 @@ function getNetworkData(item, eventStart, hasTimingHeaders = evaluateAccessToRes
|
|
|
94
93
|
ttfb,
|
|
95
94
|
serverTime,
|
|
96
95
|
networkTime,
|
|
97
|
-
requestStart:
|
|
96
|
+
requestStart: requestStartRelative,
|
|
98
97
|
...getSizeObject(transferSize)
|
|
99
98
|
};
|
|
100
99
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { getInvalidChildrenCount } from '../viewport-observer/utils/check-display-content';
|
|
1
3
|
import { calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
|
|
2
4
|
import getViewportHeight from './utils/get-viewport-height';
|
|
3
5
|
import getViewportWidth from './utils/get-viewport-width';
|
|
@@ -41,6 +43,9 @@ export default class AbstractVCCalculatorBase {
|
|
|
41
43
|
async calculateWithDebugInfo(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries) {
|
|
42
44
|
var _window, _window2, _window3, _window5;
|
|
43
45
|
const percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
|
|
46
|
+
if (fg('platform_ufo_send_vc_100')) {
|
|
47
|
+
percentiles.push(100);
|
|
48
|
+
}
|
|
44
49
|
const viewportEntries = this.filterViewportEntries(filteredEntries);
|
|
45
50
|
const vcLogs = await calculateTTVCPercentilesWithDebugInfo({
|
|
46
51
|
viewport: {
|
|
@@ -241,6 +246,9 @@ export default class AbstractVCCalculatorBase {
|
|
|
241
246
|
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
242
247
|
};
|
|
243
248
|
result.ratios = this.calculateRatios(filteredEntries);
|
|
249
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
250
|
+
result.childrenIgnoredCount = getInvalidChildrenCount();
|
|
251
|
+
}
|
|
244
252
|
return result;
|
|
245
253
|
}
|
|
246
254
|
}
|
|
@@ -6,6 +6,7 @@ import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placehol
|
|
|
6
6
|
import { createIntersectionObserver } from './intersection-observer';
|
|
7
7
|
import createMutationObserver from './mutation-observer';
|
|
8
8
|
import createPerformanceObserver from './performance-observer';
|
|
9
|
+
import checkCssProperty from './utils/check-display-content';
|
|
9
10
|
import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
|
|
10
11
|
import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
|
|
11
12
|
function isElementVisible(element) {
|
|
@@ -101,7 +102,6 @@ export default class ViewportObserver {
|
|
|
101
102
|
});
|
|
102
103
|
const targetNode = target.deref();
|
|
103
104
|
for (const addedNodeRef of addedNodes) {
|
|
104
|
-
var _this$intersectionObs9;
|
|
105
105
|
const addedNode = addedNodeRef.deref();
|
|
106
106
|
if (!addedNode) {
|
|
107
107
|
continue;
|
|
@@ -194,7 +194,17 @@ export default class ViewportObserver {
|
|
|
194
194
|
(_this$intersectionObs8 = this.intersectionObserver) === null || _this$intersectionObs8 === void 0 ? void 0 : _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
198
|
+
// Check if the target has display:content css property, return array of valid targets
|
|
199
|
+
const validTargets = checkCssProperty(addedNode);
|
|
200
|
+
for (const validTarget of validTargets) {
|
|
201
|
+
var _this$intersectionObs9;
|
|
202
|
+
(_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
var _this$intersectionObs0;
|
|
206
|
+
(_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 ? void 0 : _this$intersectionObs0.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
207
|
+
}
|
|
198
208
|
}
|
|
199
209
|
});
|
|
200
210
|
_defineProperty(this, "handleAttributeMutation", ({
|
|
@@ -203,8 +213,8 @@ export default class ViewportObserver {
|
|
|
203
213
|
oldValue,
|
|
204
214
|
newValue
|
|
205
215
|
}) => {
|
|
206
|
-
var _this$
|
|
207
|
-
(_this$
|
|
216
|
+
var _this$intersectionObs1;
|
|
217
|
+
(_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 ? void 0 : _this$intersectionObs1.watchAndTag(target, ({
|
|
208
218
|
target,
|
|
209
219
|
rect
|
|
210
220
|
}) => {
|
|
@@ -331,12 +341,12 @@ export default class ViewportObserver {
|
|
|
331
341
|
this.isStarted = true;
|
|
332
342
|
}
|
|
333
343
|
stop() {
|
|
334
|
-
var _this$mutationObserve2, _this$
|
|
344
|
+
var _this$mutationObserve2, _this$intersectionObs10, _this$performanceObse2;
|
|
335
345
|
if (!this.isStarted) {
|
|
336
346
|
return;
|
|
337
347
|
}
|
|
338
348
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 ? void 0 : _this$mutationObserve2.disconnect();
|
|
339
|
-
(_this$
|
|
349
|
+
(_this$intersectionObs10 = this.intersectionObserver) === null || _this$intersectionObs10 === void 0 ? void 0 : _this$intersectionObs10.disconnect();
|
|
340
350
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 ? void 0 : _this$performanceObse2.disconnect();
|
|
341
351
|
this.isStarted = false;
|
|
342
352
|
// Clean up caches when stopping
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { checkedChildrenCache, incrementCheckedInvalidChildrenCount } from '../utils/check-display-content';
|
|
1
3
|
function isValidEntry(entry) {
|
|
2
4
|
return entry.isIntersecting && entry.intersectionRect.width > 0 && entry.intersectionRect.height > 0;
|
|
3
5
|
}
|
|
@@ -15,6 +17,13 @@ export function createIntersectionObserver({
|
|
|
15
17
|
entries.forEach(entry => {
|
|
16
18
|
var _mutationTag;
|
|
17
19
|
if (!(entry.target instanceof HTMLElement) || !isValidEntry(entry)) {
|
|
20
|
+
// TODO: Remove this logic when analysis is complete
|
|
21
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
22
|
+
if (entry.target instanceof HTMLElement && !isValidEntry(entry) && checkedChildrenCache.get(entry.target) === false) {
|
|
23
|
+
incrementCheckedInvalidChildrenCount();
|
|
24
|
+
checkedChildrenCache.set(entry.target, true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
20
29
|
let mutationTag = null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// TODO: Remove this cache when analysis is complete - it is used to track whether direct children elements will be ignored by the observer
|
|
2
|
+
export const checkedChildrenCache = new WeakMap();
|
|
3
|
+
let checkedInvalidChildrenCount = 0;
|
|
4
|
+
export function incrementCheckedInvalidChildrenCount() {
|
|
5
|
+
checkedInvalidChildrenCount++;
|
|
6
|
+
}
|
|
7
|
+
export function getInvalidChildrenCount() {
|
|
8
|
+
return checkedInvalidChildrenCount;
|
|
9
|
+
}
|
|
10
|
+
export default function checkCssProperty(element) {
|
|
11
|
+
const computedStyle = window.getComputedStyle(element);
|
|
12
|
+
if (computedStyle.display === 'contents') {
|
|
13
|
+
// If display is 'contents', we return the direct children of the element
|
|
14
|
+
const result = [];
|
|
15
|
+
for (const child of element.children) {
|
|
16
|
+
if (child instanceof HTMLElement) {
|
|
17
|
+
if (!checkedChildrenCache.has(child)) {
|
|
18
|
+
// TODO: Remove this cache when analysis is complete
|
|
19
|
+
checkedChildrenCache.set(child, false);
|
|
20
|
+
}
|
|
21
|
+
result.push(child);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
return [element];
|
|
27
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { getConfig as getConfigUFO } from '../config';
|
|
6
5
|
import { roundEpsilon } from '../round-number';
|
|
7
6
|
import { getConfig } from './common/utils/config';
|
|
@@ -95,7 +94,7 @@ function getNetworkData(item, eventStart) {
|
|
|
95
94
|
ttfb: ttfb,
|
|
96
95
|
serverTime: serverTime,
|
|
97
96
|
networkTime: networkTime,
|
|
98
|
-
requestStart:
|
|
97
|
+
requestStart: requestStartRelative
|
|
99
98
|
}, getSizeObject(transferSize));
|
|
100
99
|
}
|
|
101
100
|
export function getResourceTimings(interactionStart, interactionEnd) {
|
|
@@ -10,6 +10,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
10
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
11
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { getInvalidChildrenCount } from '../viewport-observer/utils/check-display-content';
|
|
13
15
|
import { calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
|
|
14
16
|
import getViewportHeight from './utils/get-viewport-height';
|
|
15
17
|
import getViewportWidth from './utils/get-viewport-width';
|
|
@@ -84,8 +86,11 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
84
86
|
while (1) switch (_context.prev = _context.next) {
|
|
85
87
|
case 0:
|
|
86
88
|
percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
|
|
89
|
+
if (fg('platform_ufo_send_vc_100')) {
|
|
90
|
+
percentiles.push(100);
|
|
91
|
+
}
|
|
87
92
|
viewportEntries = this.filterViewportEntries(filteredEntries);
|
|
88
|
-
_context.next =
|
|
93
|
+
_context.next = 5;
|
|
89
94
|
return calculateTTVCPercentilesWithDebugInfo({
|
|
90
95
|
viewport: {
|
|
91
96
|
width: getViewportWidth(),
|
|
@@ -95,31 +100,31 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
95
100
|
stopTime: stopTime,
|
|
96
101
|
orderedEntries: viewportEntries
|
|
97
102
|
});
|
|
98
|
-
case
|
|
103
|
+
case 5:
|
|
99
104
|
vcLogs = _context.sent;
|
|
100
105
|
vcDetails = {};
|
|
101
106
|
percentileIndex = 0;
|
|
102
107
|
entryDataBuffer = new Set();
|
|
103
108
|
if (!vcLogs) {
|
|
104
|
-
_context.next =
|
|
109
|
+
_context.next = 29;
|
|
105
110
|
break;
|
|
106
111
|
}
|
|
107
112
|
_iterator3 = _createForOfIteratorHelper(vcLogs);
|
|
108
|
-
_context.prev =
|
|
113
|
+
_context.prev = 11;
|
|
109
114
|
_iterator3.s();
|
|
110
|
-
case
|
|
115
|
+
case 13:
|
|
111
116
|
if ((_step3 = _iterator3.n()).done) {
|
|
112
|
-
_context.next =
|
|
117
|
+
_context.next = 21;
|
|
113
118
|
break;
|
|
114
119
|
}
|
|
115
120
|
_entry2 = _step3.value;
|
|
116
121
|
time = _entry2.time, viewportPercentage = _entry2.viewportPercentage, entries = _entry2.entries; // Only process entries if we haven't reached all percentiles
|
|
117
122
|
if (!(percentileIndex >= percentiles.length)) {
|
|
118
|
-
_context.next =
|
|
123
|
+
_context.next = 18;
|
|
119
124
|
break;
|
|
120
125
|
}
|
|
121
|
-
return _context.abrupt("break",
|
|
122
|
-
case
|
|
126
|
+
return _context.abrupt("break", 21);
|
|
127
|
+
case 18:
|
|
123
128
|
// Check if this entry matches any checkpoint percentiles
|
|
124
129
|
if (viewportPercentage >= percentiles[percentileIndex]) {
|
|
125
130
|
elementNames = entries.map(function (e) {
|
|
@@ -141,21 +146,21 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
141
146
|
return entryDataBuffer.add(e);
|
|
142
147
|
});
|
|
143
148
|
}
|
|
144
|
-
case
|
|
145
|
-
_context.next =
|
|
149
|
+
case 19:
|
|
150
|
+
_context.next = 13;
|
|
146
151
|
break;
|
|
147
|
-
case
|
|
148
|
-
_context.next =
|
|
152
|
+
case 21:
|
|
153
|
+
_context.next = 26;
|
|
149
154
|
break;
|
|
150
|
-
case
|
|
151
|
-
_context.prev =
|
|
152
|
-
_context.t0 = _context["catch"](
|
|
155
|
+
case 23:
|
|
156
|
+
_context.prev = 23;
|
|
157
|
+
_context.t0 = _context["catch"](11);
|
|
153
158
|
_iterator3.e(_context.t0);
|
|
154
|
-
case
|
|
155
|
-
_context.prev =
|
|
159
|
+
case 26:
|
|
160
|
+
_context.prev = 26;
|
|
156
161
|
_iterator3.f();
|
|
157
|
-
return _context.finish(
|
|
158
|
-
case
|
|
162
|
+
return _context.finish(26);
|
|
163
|
+
case 29:
|
|
159
164
|
// Fill in any missing percentiles with the last known values
|
|
160
165
|
previousResult = {
|
|
161
166
|
t: 0,
|
|
@@ -294,11 +299,11 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
return _context.abrupt("return", vcDetails);
|
|
297
|
-
case
|
|
302
|
+
case 39:
|
|
298
303
|
case "end":
|
|
299
304
|
return _context.stop();
|
|
300
305
|
}
|
|
301
|
-
}, _callee, this, [[
|
|
306
|
+
}, _callee, this, [[11, 23, 26, 29]]);
|
|
302
307
|
}));
|
|
303
308
|
function calculateWithDebugInfo(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
|
|
304
309
|
return _calculateWithDebugInfo.apply(this, arguments);
|
|
@@ -345,8 +350,11 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
345
350
|
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
346
351
|
};
|
|
347
352
|
result.ratios = this.calculateRatios(filteredEntries);
|
|
353
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
354
|
+
result.childrenIgnoredCount = getInvalidChildrenCount();
|
|
355
|
+
}
|
|
348
356
|
return _context2.abrupt("return", result);
|
|
349
|
-
case
|
|
357
|
+
case 14:
|
|
350
358
|
case "end":
|
|
351
359
|
return _context2.stop();
|
|
352
360
|
}
|
|
@@ -13,6 +13,7 @@ import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placehol
|
|
|
13
13
|
import { createIntersectionObserver } from './intersection-observer';
|
|
14
14
|
import createMutationObserver from './mutation-observer';
|
|
15
15
|
import createPerformanceObserver from './performance-observer';
|
|
16
|
+
import checkCssProperty from './utils/check-display-content';
|
|
16
17
|
import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
|
|
17
18
|
import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
|
|
18
19
|
function isElementVisible(element) {
|
|
@@ -114,8 +115,7 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
114
115
|
_iterator = _createForOfIteratorHelper(addedNodes);
|
|
115
116
|
_context2.prev = 4;
|
|
116
117
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
117
|
-
var _this$intersectionObs9;
|
|
118
|
-
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8;
|
|
118
|
+
var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8, validTargets, _iterator2, _step2, _this$intersectionObs9, validTarget, _this$intersectionObs0;
|
|
119
119
|
return _regeneratorRuntime.wrap(function _loop$(_context) {
|
|
120
120
|
while (1) switch (_context.prev = _context.next) {
|
|
121
121
|
case 0:
|
|
@@ -245,7 +245,23 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
245
245
|
(_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
|
|
246
246
|
return _context.abrupt("return", 0);
|
|
247
247
|
case 54:
|
|
248
|
-
|
|
248
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
249
|
+
// Check if the target has display:content css property, return array of valid targets
|
|
250
|
+
validTargets = checkCssProperty(addedNode);
|
|
251
|
+
_iterator2 = _createForOfIteratorHelper(validTargets);
|
|
252
|
+
try {
|
|
253
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
254
|
+
validTarget = _step2.value;
|
|
255
|
+
(_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
_iterator2.e(err);
|
|
259
|
+
} finally {
|
|
260
|
+
_iterator2.f();
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
(_this$intersectionObs0 = _this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
264
|
+
}
|
|
249
265
|
case 55:
|
|
250
266
|
case "end":
|
|
251
267
|
return _context.stop();
|
|
@@ -291,12 +307,12 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
291
307
|
};
|
|
292
308
|
}());
|
|
293
309
|
_defineProperty(this, "handleAttributeMutation", function (_ref6) {
|
|
294
|
-
var _this$
|
|
310
|
+
var _this$intersectionObs1;
|
|
295
311
|
var target = _ref6.target,
|
|
296
312
|
attributeName = _ref6.attributeName,
|
|
297
313
|
oldValue = _ref6.oldValue,
|
|
298
314
|
newValue = _ref6.newValue;
|
|
299
|
-
(_this$
|
|
315
|
+
(_this$intersectionObs1 = _this.intersectionObserver) === null || _this$intersectionObs1 === void 0 || _this$intersectionObs1.watchAndTag(target, function (_ref7) {
|
|
300
316
|
var target = _ref7.target,
|
|
301
317
|
rect = _ref7.rect;
|
|
302
318
|
if (isContainedWithinMediaWrapper(target)) {
|
|
@@ -359,11 +375,11 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
359
375
|
_defineProperty(this, "handleLayoutShift", function (_ref8) {
|
|
360
376
|
var time = _ref8.time,
|
|
361
377
|
changedRects = _ref8.changedRects;
|
|
362
|
-
var
|
|
363
|
-
|
|
378
|
+
var _iterator3 = _createForOfIteratorHelper(changedRects),
|
|
379
|
+
_step3;
|
|
364
380
|
try {
|
|
365
|
-
for (
|
|
366
|
-
var changedRect =
|
|
381
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
382
|
+
var changedRect = _step3.value;
|
|
367
383
|
var target = changedRect.node;
|
|
368
384
|
if (target) {
|
|
369
385
|
_this.onChange({
|
|
@@ -377,9 +393,9 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
377
393
|
}
|
|
378
394
|
}
|
|
379
395
|
} catch (err) {
|
|
380
|
-
|
|
396
|
+
_iterator3.e(err);
|
|
381
397
|
} finally {
|
|
382
|
-
|
|
398
|
+
_iterator3.f();
|
|
383
399
|
}
|
|
384
400
|
});
|
|
385
401
|
this.mapVisibleNodeRects = new WeakMap();
|
|
@@ -436,12 +452,12 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
436
452
|
}, {
|
|
437
453
|
key: "stop",
|
|
438
454
|
value: function stop() {
|
|
439
|
-
var _this$mutationObserve2, _this$
|
|
455
|
+
var _this$mutationObserve2, _this$intersectionObs10, _this$performanceObse2;
|
|
440
456
|
if (!this.isStarted) {
|
|
441
457
|
return;
|
|
442
458
|
}
|
|
443
459
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
444
|
-
(_this$
|
|
460
|
+
(_this$intersectionObs10 = this.intersectionObserver) === null || _this$intersectionObs10 === void 0 || _this$intersectionObs10.disconnect();
|
|
445
461
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
|
|
446
462
|
this.isStarted = false;
|
|
447
463
|
// Clean up caches when stopping
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { checkedChildrenCache, incrementCheckedInvalidChildrenCount } from '../utils/check-display-content';
|
|
1
3
|
function isValidEntry(entry) {
|
|
2
4
|
return entry.isIntersecting && entry.intersectionRect.width > 0 && entry.intersectionRect.height > 0;
|
|
3
5
|
}
|
|
@@ -13,6 +15,13 @@ export function createIntersectionObserver(_ref) {
|
|
|
13
15
|
var startTime = performance.now();
|
|
14
16
|
entries.forEach(function (entry) {
|
|
15
17
|
if (!(entry.target instanceof HTMLElement) || !isValidEntry(entry)) {
|
|
18
|
+
// TODO: Remove this logic when analysis is complete
|
|
19
|
+
if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
|
|
20
|
+
if (entry.target instanceof HTMLElement && !isValidEntry(entry) && checkedChildrenCache.get(entry.target) === false) {
|
|
21
|
+
incrementCheckedInvalidChildrenCount();
|
|
22
|
+
checkedChildrenCache.set(entry.target, true);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
16
25
|
return;
|
|
17
26
|
}
|
|
18
27
|
var mutationTag = null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
// TODO: Remove this cache when analysis is complete - it is used to track whether direct children elements will be ignored by the observer
|
|
5
|
+
export var checkedChildrenCache = new WeakMap();
|
|
6
|
+
var checkedInvalidChildrenCount = 0;
|
|
7
|
+
export function incrementCheckedInvalidChildrenCount() {
|
|
8
|
+
checkedInvalidChildrenCount++;
|
|
9
|
+
}
|
|
10
|
+
export function getInvalidChildrenCount() {
|
|
11
|
+
return checkedInvalidChildrenCount;
|
|
12
|
+
}
|
|
13
|
+
export default function checkCssProperty(element) {
|
|
14
|
+
var computedStyle = window.getComputedStyle(element);
|
|
15
|
+
if (computedStyle.display === 'contents') {
|
|
16
|
+
// If display is 'contents', we return the direct children of the element
|
|
17
|
+
var result = [];
|
|
18
|
+
var _iterator = _createForOfIteratorHelper(element.children),
|
|
19
|
+
_step;
|
|
20
|
+
try {
|
|
21
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
22
|
+
var child = _step.value;
|
|
23
|
+
if (child instanceof HTMLElement) {
|
|
24
|
+
if (!checkedChildrenCache.has(child)) {
|
|
25
|
+
// TODO: Remove this cache when analysis is complete
|
|
26
|
+
checkedChildrenCache.set(child, false);
|
|
27
|
+
}
|
|
28
|
+
result.push(child);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
return [element];
|
|
39
|
+
}
|
|
@@ -115,6 +115,7 @@ export type RevisionPayloadEntry = {
|
|
|
115
115
|
vcDetails?: RevisionPayloadVCDetails;
|
|
116
116
|
ratios?: VCRatioType;
|
|
117
117
|
abortReason?: VCAbortReason | null;
|
|
118
|
+
childrenIgnoredCount?: number;
|
|
118
119
|
};
|
|
119
120
|
export type RevisionPayload = RevisionPayloadEntry[];
|
|
120
121
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const checkedChildrenCache: WeakMap<HTMLElement, boolean>;
|
|
2
|
+
export declare function incrementCheckedInvalidChildrenCount(): void;
|
|
3
|
+
export declare function getInvalidChildrenCount(): number;
|
|
4
|
+
export default function checkCssProperty(element: HTMLElement): Element[];
|
|
@@ -115,6 +115,7 @@ export type RevisionPayloadEntry = {
|
|
|
115
115
|
vcDetails?: RevisionPayloadVCDetails;
|
|
116
116
|
ratios?: VCRatioType;
|
|
117
117
|
abortReason?: VCAbortReason | null;
|
|
118
|
+
childrenIgnoredCount?: number;
|
|
118
119
|
};
|
|
119
120
|
export type RevisionPayload = RevisionPayloadEntry[];
|
|
120
121
|
export {};
|
package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-display-content.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const checkedChildrenCache: WeakMap<HTMLElement, boolean>;
|
|
2
|
+
export declare function incrementCheckedInvalidChildrenCount(): void;
|
|
3
|
+
export declare function getInvalidChildrenCount(): number;
|
|
4
|
+
export default function checkCssProperty(element: HTMLElement): Element[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -135,9 +135,6 @@
|
|
|
135
135
|
"platform_ufo_enable_media_for_ttvc_v3": {
|
|
136
136
|
"type": "boolean"
|
|
137
137
|
},
|
|
138
|
-
"ufo_return_relative_request_start": {
|
|
139
|
-
"type": "boolean"
|
|
140
|
-
},
|
|
141
138
|
"platform_ufo_remove_deprecated_config_fields": {
|
|
142
139
|
"type": "boolean"
|
|
143
140
|
},
|
|
@@ -197,6 +194,12 @@
|
|
|
197
194
|
},
|
|
198
195
|
"platform_ufo_ssr_placeholder_resolution_ttvc_v3": {
|
|
199
196
|
"type": "boolean"
|
|
197
|
+
},
|
|
198
|
+
"platform_ufo_send_vc_100": {
|
|
199
|
+
"type": "boolean"
|
|
200
|
+
},
|
|
201
|
+
"platform_ufo_display_content_resolution_ttvc_v3": {
|
|
202
|
+
"type": "boolean"
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
}
|